SELECT statement question (1 Viewer)

DBug

Registered User.
Local time
Today, 07:27
Joined
Jan 3, 2017
Messages
24
Set dbSAP = CurrentDb

On Error GoTo Err_Exit:

'select from Redirects Table
strSQL = "SELECT * FROM ReDirects WHERE Redirect = True"
Set rstRedirects = dbSAP.OpenRecordset(strSQL, dbOpenDynaset)

MsgBox(rstRedirects!Name)


The above code will select the first record from ReDirects even though all the records have the field Redirect set to False. I would expect it not to return any
 

MarkK

bit cruncher
Local time
Yesterday, 23:27
Joined
Mar 17, 2004
Messages
8,180
What do you get if you just run this SQL in a new query...
Code:
SELECT Typename(Redirect) FROM ReDirects
Your WHERE clause might fail that way if the your 'Redirect' field is not boolean.

Mark
 

DBug

Registered User.
Local time
Today, 07:27
Joined
Jan 3, 2017
Messages
24
i just realised my mistake, another part of the code was setting the first records Redirect to true before calling this code. Its all working now
 

Users who are viewing this thread

Top Bottom