Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Developer Network    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
RunTime Error 3061
Ashlyn Talley 
    
4 years ago
Hello, thought Ive been doing pretty good using the Query Designer to help with my SQL statements but Im finding myself humbled with this one. Im trying to return a record set using similar if not far less complex criteria than I have before in this project but it seems I cannot get past this nagging error.
PatientID (primary key/integer)
Subroutine: cmdPDF_Click

Seems when I use the below statement, hardcoding a PatientID value (402), Im error free.

Set rs3 = db.OpenRecordset("SELECT TOP 6 SchedulingT.*, SchedulingT.HasBeenInvoiced " & _
    " FROM SchedulingT " & _
    " WHERE (((SchedulingT.PatientID) = 402) And ((SchedulingT.HasBeenInvoiced) = False))" & _
    " ORDER BY SchedulingT.DateTime DESC;", dbOpenDynaset, dbSeeChanges)
*******************************************************************************
But when having the PatientID referenced from an open form I receive a continuing error code 3061 & message of Too few parameters. Expected 1

Set rs3 = db.OpenRecordset("SELECT TOP 6 SchedulingT.*, SchedulingT.HasBeenInvoiced " & _
    " FROM SchedulingT " & _
    " WHERE (((SchedulingT.PatientID) = [Forms]![PatientF]![PatientID]) And ((SchedulingT.HasBeenInvoiced) = False))" & _
    " ORDER BY SchedulingT.DateTime DESC;", dbOpenDynaset, dbSeeChanges)

As mentioned, I have used very similar SQL statements to open Recordsets from this same table, seems I may have seen this error before but forgot how to resolve. Thanks
Ashlyn Talley OP  @Reply  
    
4 years ago

Kevin Robertson  @Reply  
          
4 years ago
Try this:

Set rs3 = db.OpenRecordset("SELECT TOP 6 SchedulingT.*, SchedulingT.HasBeenInvoiced " & _
    " FROM SchedulingT " & _
    " WHERE (((SchedulingT.PatientID) =" & [Forms]![PatientF]![PatientID] & ") And ((SchedulingT.HasBeenInvoiced) = False))" & _
    " ORDER BY SchedulingT.DateTime DESC;", dbOpenDynaset, dbSeeChanges)
Ashlyn Talley OP  @Reply  
    
4 years ago
Thank you much Kevin, that was absolutely spot on, no longer receiving an error and the recordset is performing as expected. Of course couldn't help but know the error had to do with concatenating (SchedulingT.PatientID) and referencing the open form. Looking at how you worked it seems an easy fix. I think of course made it harder than need be. Thanks again!

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Developer Network.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/17/2026 9:44:13 AM. PLT: 1s