Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Evaluating recordset

Status
Not open for further replies.

Zbob

MIS
Apr 25, 2002
94
US
I have a recordset that has one value.

How do I dim it as a double to compare it to another number

I have an order form with item and Qty, my select checks the case pack for the item, to make sure they are ordering in case packs

'Declare variables
Dim Ordqty As String
Dim Item As String
Dim CPstmt As String
Dim cp As New ERSRecSet
Dim cpvalue As Double

'Dim adorecordset As New ADOBD.recordset
'adoconnect.provider = "Pervasive ODBC Client Interface"
'adoconnect.open_

'set variables
Ordqty = macForm.Qty.Text
Item = macForm.ItemNo.Text

' setup the connection string for use with the record set
p_sDataPath = "DB=" + macForm.ConnInfo.BtrPath
g_sBTRPath = macForm.ConnInfo.BtrPath
' Create a DSN-less connection to the Macola70 database.
g_sConnectString = "DRIVER=" & _
"{Macola 32-BIT Btrieve (*.dta)}; " & _
"DFE=BTR;AS=4096;" & p_sDataPath

' set the connect string here
cp.ConnectString = g_sConnectString

'Construct SQL statment
CPstmt = "SELECT IMITMIDX.USER_FIELD_4 "
CPstmt = CPstmt & "FROM IMITMIDX WHERE IMITMIDX.ITEM_NO = '" & Item & "'"


cp.open CPstmt
cpdouble = ("IMITMIDX.USER_FIELD_4")

If cpvalue = 0 Then
MsgBox "it works"
End If
End Sub



 
I think that what you want to do is compare the number returned by the recordset to another number. Depending on the datatype your recordset returns you may need to do a conversion of some sort.

Think about using the 'IsNumeric' function to check if it is a number and then the CDbl() function to convert the number to a double.

If isnumeric(<recordset value>) then dblVariable=CDbl(<recordset value>)

If I missed the mark then please clarify. Thanks and Good Luck!

zemp
 
Your are right I do want to compare the number returned.

How do I extract the number from the recordset?

Maybe thats not the right question, But I'm unsure how to handle the recordset once It is defined.

Thanks
 
The recordset is made up of fields. If you know which field you are looking for you just need to assign it to what you need to assign it to. Does that make sense.

variable = rs![Number] ' or rs.fields(&quot;Number&quot;)

That is the syntax for an ADO recordset called 'rs' and a field called 'Number'. 'Variable' could be am actual variable, or a control or a function parameter, etc. Thanks and Good Luck!

zemp
 
Thanks,

Do you know anyway to display the value of variable?

Msgbox or other.
 
In a text box: text1=str(variable)

In a msgbox: msgbox=&quot;Variable = &quot; & variable Thanks and Good Luck!

zemp
 
Thanks

You are making my life very easy.
 
I am dividing order qty by case pack to determine if the order is in full cases.

If the value is not a whole number I want to prompt user to change order qty.

Is there a function to determin if whole number?
Or no decimal?

Thanks
 
Use the mod function. It will return your remainder and if it is zero then you have a full case. For example.

if 10 mod 5 = 0 then...

Where 10 is the quantity and 5 is the number in a case. Thanks and Good Luck!

zemp
 
Try using the modulus operator (returns the remainder).

If Qty Mod Pack = 0 Then
'Full packs
Else
'There not all full packs
End If
 
Mod is an operator and not a function, my mistake. Thanks for pointing that out FRoeCassNet. Thanks and Good Luck!

zemp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top