Share via

Set rs code not working in Access

Anonymous
2024-01-10T14:20:36+00:00

Hi there,

I am having issues with the bolded line of the following code in that I get a 3061 error: "Too few parameters. Expected 1." The following code works fine where I am pulling data from a table, but not from any queries. Can anyone see the problem with this?

Set db = CurrentDb

**Set rs = db.OpenRecordset("GBO", dbOpenSnapshot)** 

With rs 

    If .RecordCount <> 0 Then 

        Do While Not .EOF 

            sDataArray = sDataArray & "                       {ClientID: """ & ![Client ID] & """, Appointmentdate: """ & ![Appointment date] & """, GoalProgress1: """ & ![Goal progress 1] & """}," & vbCrLf 

            .MoveNext 

        Loop 

    End If 

.Close 

End With

Set rs = Nothing

Set db = Nothing

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

19 answers

Sort by: Most helpful
  1. ScottGem 68,830 Reputation points Volunteer Moderator
    2024-01-10T16:20:19+00:00

    Can you run the GBO query directly without a problem? Are you sure it is the SET rs line throwing the error? What does your DIM rs statement look like?

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2024-01-10T15:51:03+00:00

    Hi, Thank you for your response. Unfortunately that does not make a difference.

    Was this answer helpful?

    0 comments No comments
  3. George Hepworth 22,855 Reputation points Volunteer Moderator
    2024-01-10T14:54:24+00:00

    Try "SELECT * FROM GBO"

    Does that make any difference?

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2024-01-10T14:48:01+00:00

    Hi HansV,

    Thank you for your response - no the query does not display a parameter prompt when opened directly, and it does not refer to a control on a form.

    Was this answer helpful?

    0 comments No comments
  5. HansV 462.6K Reputation points
    2024-01-10T14:28:24+00:00

    Does the GBO query display a parameter prompt when opened directly? Or does it refer to a control on a form?

    Was this answer helpful?

    0 comments No comments