Searching table for 2 criteria

Directlinq

Registered User.
Local time
Today, 01:33
Joined
Sep 13, 2009
Messages
67
How can i search my video table for a record that has artistid as a string in one column and VideoName as a string in another column but both in the same record.

Many Thanks
 
Modify the WHERE clause of the SQL...
Code:
"SELECT .... " & _
"FROM ...  " & _
"WHERE ArtistID = '" & <expression yielding artistid> & "' " & _
  "AND VideoName = '" & <expression yielding video name> & "'"
 
Sorry im a bit new to all this, how can i make it give me a true outcome if it exists.

Thank you
 
The outcome will be true whether it exists or not, but how do you want that outcome formulated? You can use that query up there to open a recordset. That is common. You can also set the recordsource of a form to that SQL so only the selected records appear. Or you can set the rowsource of a listbox or combobox control. You can save it a query to use another day...
You get the idea...
 
I have opened a record set as you have said but im getting this error

runtime error 3464
Data type mismatch in criteria expression


Code:
Set rs = db.OpenRecordset("Select artist_id FROM TblVideo WHERE artist_id = '" & artistid & "' " & "AND Name = '" & songname & "'")

Any ideas?
Thanks
 
Probably one of your fields is not a string in the table, probably the artist_id.
Try...
Code:
set rst = currentdb.openrecordset( _
  "SELECT artist_id " & _
  "FROM tblVideo " & _
  "WHERE artist_id = " & artistid & " " & _
    "AND Name = '" & songname & "'")
And the tidier you keep your code the fewer places bugs can hide, and the easier it is to step on them when found.
Cheers,
 

Users who are viewing this thread

Back
Top Bottom