Question DCount problem (1 Viewer)

byTimber

Registered User.
Local time
Today, 11:16
Joined
Apr 14, 2012
Messages
97
Can anyone help here:

Table is named tblLVR
Field is BusinessName

I want to check the previous existence of this name in the table.

I assign a variable tBusVar to the entered name on it's changed event
and write the following code to see if it is already in:-

If DCount("[BusinessName]", "tblLVR", "[BusinessName] = " & tBusVar) > 0 Then
MsgBox "This current record is a Duplicate"
End If

Run_time Error :'2471':
The expression passed as a query parameter produced this error '<Name entered>'

I can't understand what is happening here. Grateful for any help....
 

byTimber

Registered User.
Local time
Today, 11:16
Joined
Apr 14, 2012
Messages
97
Thanks for reply Paul, but tBusVar is a variable and not actual text; how would that play with DCount and DLookup in my situation?
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 11:16
Joined
Aug 30, 2003
Messages
36,137
It would be the same as the form example, replacing the form reference with your variable.
 

byTimber

Registered User.
Local time
Today, 11:16
Joined
Apr 14, 2012
Messages
97
Got it! - Thanks Paul. Best wishes, Roger ..
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 11:16
Joined
Aug 30, 2003
Messages
36,137
Happy to help Roger!
 

Users who are viewing this thread

Top Bottom