PDA

View Full Version : If Then statement based on a query



ironj32
06-08-2007, 07:38 AM
I'm not sure what the code should look like. I want to use an "IF" statement based upon a query result. What I have below does not work.

If qryFindUnmatchedPropMngr![usbmanager] = Null Then
cmdAppendData.Enabled = True
Else: cmdAppendData.Visible = False
End If

mattj
06-08-2007, 08:10 AM
You can't reference a query result like this. Use a Dlookup statement instead.
If IsNull(DLookup("[usbmanager]","qryFindUnmatchedPropMngr")) Then
cmdAppendData.Enabled = True
Else
cmdAppendData.Visible = False
End If

If your query returns more than one result you will need to specify criteria in the Dlookup statement.

HTH
Matt