View Full Version : Duplicate Values


mugman17
02-04-2001, 06:39 PM
I have a command button in which I am trying to locate a duplicate entry. Here is the coding for it:

Dim s As String
Dim strField As String

If IsNull(Me![cmboBuyerID]) = True Then
MsgBox ("You need a buyer")
Exit Sub
End If

If IsNull(Me![cmboSellerID]) = True Then
MsgBox ("You need a seller")
Exit Sub
End If

s = "[SellerId]='" & Me![cmboSellerID] & "' AND "
s = s & "[BuyerId]='" & Me![cmboBuyerID] & "' AND "
s = s & "[TransactionDate]=#" & Me![transdate] & "# "
strField = DLookup("DealID", "salessheet", s)

If Len(strField) > 0 Then
MsgBox "That value already exists", vbOKCancel, "Duplicate Value"
Cancel = True
Exit Sub
Else
MsgBox "HA HA", vbOKCancel
Exit Sub
End If

My problem if the I continue to get an "Invalid Use of Null" error. I have tried to add several things and I am still getting it.

Rich
02-05-2001, 12:14 AM
Leave out the =True you don't need it.
If IsNull(Me.cmboBuyerID) Then
etc.

mugman17
02-05-2001, 01:58 PM
Its the Dlookup I am having a problem with. I am getting strSomeField ="" if there are no entries. And I cant seem to find a code that will remove the "invalid use of null" warning.

Sorry, still learning.