hi all.
i have a button on the main menu of my application to display the largest bar code (the primary key) in use. it works fine if everything in there is a number. I have declared this field as a string because i was told to allow for changes in the scheme for bar codes... ie they might have alphanumeric characters later on.
my problem is this.. i want to check if a certain value can be converted to a double. if not, i want to call another subroutine. this is the line i try to do this in (and it doesn't work):
If CDbl(s.Fields(0).Value) Then
blah blah
here is all the code for this button:
Private Sub cmdMaxBC_Click()
Dim intMaxBC As Double
Dim intNext As Double
Dim s As ADODB.Recordset
Set s = New ADODB.Recordset
s.Open "Select BarCode from [ItemInfo]", CodeProject.Connection, adOpenStatic
If s.RecordCount = 0 Then
MsgBox ("There are no items in the inventory"
Else
intMaxBC = CDbl(s.Fields(0))
's.MoveNext
Do While Not s.EOF
If CDbl(s.Fields(0).Value) Then
intNext = CDbl(s.Fields(0).Value)
If intNext > intMaxBC Then
intMaxBC = intNext
End If
s.MoveNext
Else
MaxBCStr
End If
Loop
MsgBox ("The largest bar code in use is " & intMaxBC & "."
End If
End Sub
thanks in advance!
drew
i have a button on the main menu of my application to display the largest bar code (the primary key) in use. it works fine if everything in there is a number. I have declared this field as a string because i was told to allow for changes in the scheme for bar codes... ie they might have alphanumeric characters later on.
my problem is this.. i want to check if a certain value can be converted to a double. if not, i want to call another subroutine. this is the line i try to do this in (and it doesn't work):
If CDbl(s.Fields(0).Value) Then
blah blah
here is all the code for this button:
Private Sub cmdMaxBC_Click()
Dim intMaxBC As Double
Dim intNext As Double
Dim s As ADODB.Recordset
Set s = New ADODB.Recordset
s.Open "Select BarCode from [ItemInfo]", CodeProject.Connection, adOpenStatic
If s.RecordCount = 0 Then
MsgBox ("There are no items in the inventory"
Else
intMaxBC = CDbl(s.Fields(0))
's.MoveNext
Do While Not s.EOF
If CDbl(s.Fields(0).Value) Then
intNext = CDbl(s.Fields(0).Value)
If intNext > intMaxBC Then
intMaxBC = intNext
End If
s.MoveNext
Else
MaxBCStr
End If
Loop
MsgBox ("The largest bar code in use is " & intMaxBC & "."
End If
End Sub
thanks in advance!
drew