I need some help in rewriting a working function using a string into a function based on the choice from a list box.
The function that i use now successfully is the following
Public Function ftransform()
Dim f As Form
Set f = Forms![FOrderInformation]
Dim strOrderID As String
strOrderID = InputBox("Enter order number "
If strOrderID = "" Then
Exit Function
End If
DoCmd.OpenForm "FOrderinformation", acNormal, , "OrderID=" & strOrderID
f.RecordsetClone.FindFirst "orderid = " & strOrderID
If f.RecordsetClone.NoMatch Then
MsgBox "îðäåð " & strOrderID & " no such order!"
DoCmd.OpenForm "frmCustomerOrders"
Exit Function
Else
f.Bookmark = f.RecordsetClone.Bookmark
End If
Forms![FOrderInformation]![invoicedate] = date
direct ' this is a function
End Function
However, my effort to rewrite the function refering to a list box choise results in an error.
Public Function TheNewTransform()
Dim f As Form
Set f = Forms![FOrderInformation]
Dim strOrderID As Control
strOrderID = Forms![FOrderInformation]![ListOrders]
DoCmd.OpenForm "FOrderinformation", acNormal, , "OrderID=" & strOrderID
f.RecordsetClone.FindFirst "orderid = " & strOrderID
f.Bookmark = f.RecordsetClone.Bookmark
Forms![FOrderInformation]![invoicedate] = date
direct , this is a function
End Function
I will be very grateful if someone explains me why my function works in the firts case and not in the second case
The function that i use now successfully is the following
Public Function ftransform()
Dim f As Form
Set f = Forms![FOrderInformation]
Dim strOrderID As String
strOrderID = InputBox("Enter order number "
If strOrderID = "" Then
Exit Function
End If
DoCmd.OpenForm "FOrderinformation", acNormal, , "OrderID=" & strOrderID
f.RecordsetClone.FindFirst "orderid = " & strOrderID
If f.RecordsetClone.NoMatch Then
MsgBox "îðäåð " & strOrderID & " no such order!"
DoCmd.OpenForm "frmCustomerOrders"
Exit Function
Else
f.Bookmark = f.RecordsetClone.Bookmark
End If
Forms![FOrderInformation]![invoicedate] = date
direct ' this is a function
End Function
However, my effort to rewrite the function refering to a list box choise results in an error.
Public Function TheNewTransform()
Dim f As Form
Set f = Forms![FOrderInformation]
Dim strOrderID As Control
strOrderID = Forms![FOrderInformation]![ListOrders]
DoCmd.OpenForm "FOrderinformation", acNormal, , "OrderID=" & strOrderID
f.RecordsetClone.FindFirst "orderid = " & strOrderID
f.Bookmark = f.RecordsetClone.Bookmark
Forms![FOrderInformation]![invoicedate] = date
direct , this is a function
End Function
I will be very grateful if someone explains me why my function works in the firts case and not in the second case