Dcount problem

motleyjew

Registered User.
Local time
Today, 09:24
Joined
Jan 11, 2007
Messages
109
I am having a issue with a dcount not working properly.

The table is called tblMain
In this table is a field called clientid as text
I am delcaring a field in my database called client as a string


Here is the current code:

'''''''''''''''''''''''''''''''''''''''''''''''

Dim client As String

client = Mid([ID], InStr([ID], "client_id=") + 10, IIf(Mid([ID], InStr([ID], "client_id=") + 17, 1) = "&", 7, 8))

If DCount("[clientid]", "[tblMain]", "'client' = [tblMain]![clientid]") >= 1 Then
MsgBox "Duplicate Client ID"
End If

''''''''''''''''''''''''''''''''''''''''''''''''
When I put my curser over "client" and [tblMain]![clientid], i am getting a matching number for the results. For some reason it is not counting it. I have a feeling it has something to do with the single quotes arount client. Looking for any help.

Thanks
Gregg
 
I'm going to guess:
Code:
If DCount("[clientid]", "[tblMain]", "[clientid] =" & client) >= 1 Then
   MsgBox "Duplicate Client ID"
End If
 
Thanks Rural Guy

I tried that and I got a error message "Run time error 3464 - Data type mismatch in criteria expression".

I tried to do this

DCount("[clientid]", "[tblMain]", "[clientid] =" & "'client'") >= 1

however i go back to having the same issue that there is no match. Very Curious
 
Is the ClientID a number or text?
 
My Bad!
DCount("[clientid]", "[tblMain]", "[clientid] ='" & client & "'") >= 1
 
Ignore my question, RuralGuy read my mind.
 
I found a post from yesterday that led me to the same solution RG. That is correct. Thank you so much for your help. And thank you Alc for your efforts. Have a safe holiday tomorrow.

Gregg
 

Users who are viewing this thread

Back
Top Bottom