It is coming from the form. so would it be sSQL = sSQL & "WHERE OrderNum= " Form & Me.OrderNum ?
It is coming from the form. so would it be sSQL = sSQL & "WHERE OrderNum= " Form & Me.OrderNum ?
No, "Me" refers to the form so that bit you added needs to be removed.
I'm sorry, we're in a function in a standard module? If so you need the full reference instead of Me:
sSQL = sSQL & "WHERE OrderNum= " & Forms!FormName.OrderNum
It works! Thank you. But I would like to use it on many forms. How would I do this?
Pass the order number to the function as an input parameter and use that instead of the form reference. More here if needed:
http://www.baldyweb.com/Function.htm
Sorry but this link does not provide me enough detail. OrderNum is my common parameter on each form. Could I not use something like this sSQL = sSQL & "WHERE OrderNum= " & Forms!ME.OrderNum so its not specific to a form?
Also I tried this but I get an error
No, that wouldn't work. Like:
Public Function fnCalcPct(lngOrderNum As Long) As Variant
and then use lngOrderNum instead of the form reference. You'd add it when calling the function as well, as shown in the link.