sir, question.. can i get the exact len of string when quering?

because i have two format in my TransID. The one is the 10digit for the MSAccess and the another is the 11 Digits in my MySql. So if i update all in the MySql database the problm is he read the last transId from the access and add the 1 value that must be only in MySQL transaction..


how can i query the 11digit transID only and add the value.

this is my format in my TransID that i think make me more complecated...

MsAccess = RMI-000000
MySql = RMI-A000000

thxx in advance..

Recommended Answers

All 5 Replies

Hi,
You can get the Length of String using Len Function.
For ex

Dim TransID as String
  Dim LengthOfTID as Integerr

  TransID =  "RMI-000000"
  LengthOfTID = Len ( TransID )
  
  If LengthOfTID = 10 Then
   'MSAccess
  ElseIf LengthOfTID = 11 Then
   'MSSQL
  End If

I hope it may help you.

just to correct :)
Dim LengthOfTID as Integer
Anyway selvaganapathy has given the best answer.

commented: :) +1
commented: hmmm +1

nope..that not like that.. im sorry...
sir, every transaction the transactionID incremented also...if the

for example if im in the access the transaction id goes like thiss...

RMI-A000001 'transaction number 1
RMI-A000002 'transaction number 1
RMI-A000003 'transaction number 1


for my mysql

RMI-000001 'transaction number 1
RMI-000002 'transaction number 2


now i will combine the two transID in mysql db like thiss...

RMI-000001
RMI-000002
RMI-A000001
RMI-A000002
RMI-A000003


now i want to get the last trans of mysql then add the 1 value

how...?? net repszz thx to those who reply

> Extract the last 6 digit.
> Make as String
> Convert it to Number
> Add one to that Number
> Convert again to String

Code

Dim sTransID As String
   Dim sNextID As String
   Dim lTID As Long
   
   sTransID = "RMI-A000002"
   
   lTID = Val(Right(sTransID, 6))
   lTID = lTID + 1
   sNextID = "RMI-" & Format(lTID, "000000")
   MsgBox sNextID

sNextID contains the Next Transaction ID
Also u can use for "RMI-000002"

Is this in correct sense?

thx for the reply.... i already got the code..

i query the db like this..

dim str as string
select * from transNO order by ID ''''...my "ID" is autoincremented

while not .eof
if len(!field) = 10 then
str = !field
end if

wend

str = str + 1

i will put the code for some reason regarding to same problem with me...
thxx to those who view and to those who help...

selvaganapathy
Jx_Man

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.