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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

function based on list box

Status
Not open for further replies.

primerov

Technical User
Aug 16, 2002
160
BG
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



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top