In my forms Load event I make a call to a sub procedure which sets the forms RecordSource using the following code
The RecordSource of the form is set as expected. If I call the code again with the same value for CurrentId things remain fine, however whenever I change the value of CurrentId and call the code the resultant recordset always contains zero records. If I run the exact same piece of SQL as a seperate process with the same value for CurrentId it returns the record I expect. It's as if all subsequent calls to the code to amend the RecordSource within the form are resulting in the forms existing Recordset being queried with the new criteria rather than the recordset being completely reset.
Can anyone offer any suggestions on wher I am going wrong, or which settings/properties may be causing this?
Code:
Me.RecordSource = "SELECT * FROM MyQueryName " _
& "WHERE FieldId=" & CurrentId
The RecordSource of the form is set as expected. If I call the code again with the same value for CurrentId things remain fine, however whenever I change the value of CurrentId and call the code the resultant recordset always contains zero records. If I run the exact same piece of SQL as a seperate process with the same value for CurrentId it returns the record I expect. It's as if all subsequent calls to the code to amend the RecordSource within the form are resulting in the forms existing Recordset being queried with the new criteria rather than the recordset being completely reset.
Can anyone offer any suggestions on wher I am going wrong, or which settings/properties may be causing this?