Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

SQL Statement Not returning expected results

$
0
0
I have some code that evaluates whether a field for a certain row of data is marked true.

How ever when the code runs and it is returning the recordset as not EOF - meanining if finds a record meeting that criteria - but the result is wrong - I have no records marked aas true and the resulting recordset should be - No records here is the snippett - syntactically the code is correct it just is returning a recordset when it shouldnot

strsql2 = "SELECT tblJobCard.jc_closure " _
& "From tblJobCard " _
& "WHERE jc_closure = true and tblJobCard.Job_Card_Number=" & "'" & Forms![frmcms]![Job_Card_Number] & "'"
Debug.Print strsql2


Set rst1 = CurrentDb.OpenRecordset(strsql2, dbOpenDynaset)
If Not rst.EOF Then 'meaning if a there is one record meeting the criteria

CMDsTATUS.BackColor = vbYellow ' strsql2 should return an empty recordset because jc_closure is ion fact False for this job_card_number however the code continues as if there is a resulting recordset - any ideas?

' CMDsTATUS.Enabled = False
Else
CMDsTATUS.BackColor = vbGreen - 'this should be where my code ends up and executes but it never makes it to here
End If


I have pasted the strsql2 into the query sql view and run it and it returns a record - but that record shows that jc_closure is in fact set to false.

I am going crazy over this.

I know the work around is to do a dlookup and if the value is 0 then handle it - but that is not a purist way to accomplish this and should we port over to sql server for the back-end then the dlookup will fail anyway.

thank you

Viewing all articles
Browse latest Browse all 13329

Trending Articles