Duplicate Values

mugman17

Registered User.
Local time
Today, 22:53
Joined
Nov 17, 2000
Messages
110
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.
 
Leave out the =True you don't need it.
If IsNull(Me.cmboBuyerID) Then
etc.
 
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.
 

Users who are viewing this thread

Back
Top Bottom