I have the below code which used to work perfectly well in Access 97 some years ago but now doesn't, either in Access 97 or 2003.
The problem is, once the query is created it just doesn't retrieve the recordset? If I go into the query after it has been created and retype one of the values then it does work?
I've been out of the Access game for a few years so apologies if this is something daft...
I've received a lot of help from this site in the past (indeed, this very code probably was provided some years ago), so I'm hoping for the same again...
Regards,
Adrian
If ObjectExists("Queries", "qryACK_QDF_Confirms") = True Then
MyDb.QueryDefs.Refresh
MyDb.QueryDefs.Delete "qryACK_QDF_Confirms"
MyDb.QueryDefs.Refresh
End If
Where = Null
Where = Where & " AND [Next Approver]='" + MyRs![To] + "'"
Where = Where & " AND [AckSent] = Null"
'Select Records
Set MyQdf = MyDb.CreateQueryDef("qryACK_QDF_Confirms", _
"Select * From [tblConfirmsHistory]" & ("WHERE " + Mid(Where, 6) & ";"))
The SQL looks like this once the query has been created:
SELECT *
FROM tblConfirmsHistory
WHERE (((tblConfirmsHistory.[Next Approver])='Person's Name') AND ((tblConfirmsHistory.Acksent) Is Null));
The problem is, once the query is created it just doesn't retrieve the recordset? If I go into the query after it has been created and retype one of the values then it does work?
I've been out of the Access game for a few years so apologies if this is something daft...
I've received a lot of help from this site in the past (indeed, this very code probably was provided some years ago), so I'm hoping for the same again...
Regards,
Adrian
If ObjectExists("Queries", "qryACK_QDF_Confirms") = True Then
MyDb.QueryDefs.Refresh
MyDb.QueryDefs.Delete "qryACK_QDF_Confirms"
MyDb.QueryDefs.Refresh
End If
Where = Null
Where = Where & " AND [Next Approver]='" + MyRs![To] + "'"
Where = Where & " AND [AckSent] = Null"
'Select Records
Set MyQdf = MyDb.CreateQueryDef("qryACK_QDF_Confirms", _
"Select * From [tblConfirmsHistory]" & ("WHERE " + Mid(Where, 6) & ";"))
The SQL looks like this once the query has been created:
SELECT *
FROM tblConfirmsHistory
WHERE (((tblConfirmsHistory.[Next Approver])='Person's Name') AND ((tblConfirmsHistory.Acksent) Is Null));