Brackets in VBA code

wildexodus

Registered User.
Local time
Today, 18:25
Joined
Feb 6, 2003
Messages
74
Can anyone see whats wrong with this code?



Private Sub Form_Open(Cancel As Integer)

IIF(([Forms]![frmOrder]![CustomerID])= Null([Forms]![frmCustomer]![CustomerID]), [CustomerID],[Forms]![frmOrder]![CustomerID])

End Sub


It's in the 'On open' section of my code for the form.
 
Try using the IsNull function...

IIF(IsNull([Forms]![frmOrder]![CustomerID]) = True, True, False)
 
Where do you want me to start??????????



1= you cant ask if something = NULL use ISNULL(something) instead

2= NULL is not a function, (ie. something = null(somthing) 'wont work)


You might want to look up IIf, NULL, ISNULL and NZ in the help?


I think this is what you were trying to do...

iif(nz([Forms]![frmCustomer]![CustomerID],0) = [Forms]![frmOrder]![CustomerID],[CustomerID],[Forms]![frmOrder]![CustomerID])

If its not, what is the logic behind this function (ie what r u trying to do).



PS, wont be back till after easter so hope this helps



:cool:ShadeZ:cool:
 
tried shadez code, and it sez:

Compile error - Expected: =

I am trying to enter customer details into one form and then click a next button to input order details and i want when the order form is opened for the value of the customerID on the customer form to go into the CustomerID on the order form.
 
Try this

If isnull([Forms]![frmOrder]![CustomerID]) then
me.CustomerID = [Forms]![frmOrder]![CustomerID]
Else
End if

HTH
 

Users who are viewing this thread

Back
Top Bottom