P
Paul
I'm trying to use the following code to test whether there are any records
in a recordset, but when VBA tries to run the line containing the SELECT
statement, it displays an error that says
Too few parameters. Expected 1.
Here's the code I'm using:
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT tblProject.ProjectID,
tblContacts.osUserName FROM tblProject INNER JOIN (tblContacts INNER JOIN
tblProjectContact ON tblContacts.ContactID = tblProjectContact.ContactID) ON
tblProject.ProjectID = tblProjectContact.ProjectID WHERE
(((tblProject.ProjectID)=[forms]![frmProjects]![txtProjectID]) AND
((tblContacts.osUserName)=fosUserName()));", dbOpenDynaset)
If rs.RecordCount > 0 Then
etc.
One thing that puzzles me about this is that the SELECT statement does
produce the desired records in a query. Why am I getting this message when
I try to use it in VBA?
Thanks in advance,
Paul
in a recordset, but when VBA tries to run the line containing the SELECT
statement, it displays an error that says
Too few parameters. Expected 1.
Here's the code I'm using:
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT tblProject.ProjectID,
tblContacts.osUserName FROM tblProject INNER JOIN (tblContacts INNER JOIN
tblProjectContact ON tblContacts.ContactID = tblProjectContact.ContactID) ON
tblProject.ProjectID = tblProjectContact.ProjectID WHERE
(((tblProject.ProjectID)=[forms]![frmProjects]![txtProjectID]) AND
((tblContacts.osUserName)=fosUserName()));", dbOpenDynaset)
If rs.RecordCount > 0 Then
etc.
One thing that puzzles me about this is that the SELECT statement does
produce the desired records in a query. Why am I getting this message when
I try to use it in VBA?
Thanks in advance,
Paul