how can i find out a value on a table?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

help!!!.. I have a table named "searched_by" and populated with user names. I would like to do a search (with code, not with WINDOWS "FIND") to see if a user exists on the table. How can I do this???? Can someone give me some code or point me to what i need to look for...............HELP

Luis
 
One way to do it is with the "DCount" function:

If DCount("*", InvoiceTableName, "[LastName] = 'Smith'") > 0 Then
MsgBox " Found"
Else
MsgBox " Not Found"
End If



luis said:
help!!!.. I have a table named "searched_by" and populated with user
names. I would like to do a search (with code, not with WINDOWS "FIND") to
see if a user exists on the table. How can I do this???? Can someone give me
some code or point me to what i need to look for...............HELP!
 
This is not working for me.
Notice that the error message gives another user name that's on the table. HELP!!!!!!!!!
This is the error i get.

"The Microsoft Jet database engine cannot find the input table or query 'Gary T.'. Make sure it exists and it's spelled correctly"

Here is the code i have

If DCount("*", SEARCHED_BY, "[Searched-BY] = 'susanp'") > 0 The
MsgBox " Found
Els
MsgBox " Not Found
End I

some information
Where "SEARCHED_BY" = My table nam
Where "[Searched-BY] = 'susanp'" = what i am searching for in the table. where Searched-BY is the column/Field name

Help someone!!!!!!!!!!!!
 
luis said:
This is not working for me.
Notice that the error message gives another user name that's on the table. HELP!!!!!!!!!!
This is the error i get.

"The Microsoft Jet database engine cannot find the input table or query 'Gary T.'. Make sure it exists and it's spelled correctly".

Here is the code i have.

If DCount("*", SEARCHED_BY, "[Searched-BY] = 'susanp'") > 0 Then
MsgBox " Found"
Else
MsgBox " Not Found"
End If

some information:
Where "SEARCHED_BY" = My table name
Where "[Searched-BY] = 'susanp'" = what i am searching for in the table. where Searched-BY is the column/Field name.

Help someone!!!!!!!!!!!!!

Luis,

You need quotes around the table name. Try

If DCount("*", "SEARCHED_BY", "[Searched-BY] = 'susanp'") > 0 Then
MsgBox " Found"
Else
MsgBox " Not Found"
End If


Using a variable (user_name) to hold the user name, the code would be

If DCount("*", "SEARCHED_BY", "[Searched-BY] = '" & user_name & "'") >
0 Then
MsgBox " Found"
Else
MsgBox " Not Found"
End If


HTH
 
it worked! :
thanks alot Steve..... :
may the gods shine their light upon you......and a free lap dance too.....
 
Back
Top