Defining table records within VB

Dave_cha

Registered User.
Local time
Today, 21:49
Joined
Nov 11, 2002
Messages
119
I have a form which contains a unique reference number. I want to create a button which when pressed will search a table (not bound to the form) for a record which contains this unique ref. number. I then need to check if another field within the selected record is blank or has data entered. Depending on the status of this second field I want to be able to produce two different responses.

Can anyone help?

Thanks in advance,

Dave
 
If the unique field, named CustomerID, is in a table named tblCustomer and the field with the value in question is named StreetName then...

'BEGIN CODE
Dim strStreetName as String

strStreetName = DLookUp("StreetName", "tblCustomer", "CustomerID =" & Me.CustomerID

If Len(strStreetName) > 0 then
'Take action for a non-null value
Else
'Take action for a null value
End If
'END CODE
 
Just a suggestion, but if you're checking for a null value you may have problems with the above (you can't assign a Null value to a String). Add NZ() and you should be fine :

strStreetName = NZ(DLookUp("StreetName", "tblCustomer", "CustomerID =" & Me.CustomerID),"")

HTH.

Matt.
 

Users who are viewing this thread

Back
Top Bottom