|
-
Apr 21st, 2000, 10:53 AM
#1
Hi I have succesfully set a textbox to the value of a field in a recordset obtained using SQL. so far so good.
But I want to find the highest value of all that fldOrderID and add one to it, so I can use that as a New orderID
this worked
frmNewOrder:
Call GetOrderMaster
txtOrderID = MR_OS.grstCurrentRS![fldOrderID]
standard form MR_OS:
Public Sub GetOrderMaster()
'use the glngCustomerID assinged in SetCurrentRecord to select the tblOrderMaster in a select
Set grstCurrentRS = gdbCurrent.OpenRecordset("Select * from tblOrderMaster where fldCustomerID like " & "'*" & glngCustomerID & "*'")
End Sub
the textbox shows the value of fldOrderID of the current record of the recordset.
Question: is the current record the last record in the recordset by default?
Anyway so that is working so I tried to add the abilty to find the highest value in records of the field fldOrderId and add one to it and use that as a New OrderID. so I added a global variable glngOrderID in the standard form MR_OS changed the Sub GetOrderMaster() to this
Public Sub GetOrderMaster()
glngOrderID = 0
'use the glngCustomerID assinged in SetCurrentRecord to select the tblOrderMaster in a select
Set grstCurrentRS = gdbCurrent.OpenRecordset("Select * from tblOrderMaster where fldCustomerID like " & "'*" & glngCustomerID & "*'")
'find the highest value in the fldOrderID feild and add one to that to be used as the new OrderID
'loop through the current recordset checking the fldOrderID values and set a variable to the highest value
Do Until grstCurrentRS.EOF = True
If grstCurrentRS.Fields("fldOrderID").Value > glngOrderID Then
glngOrderID = grstCurrentRS.Fields("fldOrderID").Value
End If
grstCurrentRS.MoveNext
Loop
End Sub
now when I run it I get "No Current Record" and it points to
txtOrderID = MR_OS.grstCurrentRS![fldOrderID]
in the frmNewOrderID
I want to change that eventually to
txtOrderID = glngOrderID
after finding the highest order number in the fldOrderID field in the current recordset and adding one to it, but why do I not have a current record now?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|