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
Warren Lovegrove 
     
4 years ago
Hi,

I'm getting the above error along with "To few parameters expected. Expected 1.
I'm using below code:
Private Sub EmailBtn_Click()

    Dim db As Database
    Dim rs As Recordset
    Dim Msg As String, Subject As String
    
    Set db = CurrentDb
    Set rs = db.OpenRecordset("Select * From OutgoingReviewQ where TenantID=" & TenantID)
    
    If rs!BalancePayment < 0 Then
        Subject = "Annual Outgoing Reconciliation - " & rs!FullAddress
        Msg = "Dear " & rs!FirstName & ",

" & "The anniversary of the commencement of your lease is the " & rs!StartReviewDate & ", The results show that a balance payment of " & rs!BalancePayment & "Excl. GST is due. An invoice for this balance will be forwarded in due course." & "

" & "Should you have any queries relating to the attached review please do not hesitate to call." & "

" & "Regards" & "

" & "Lovegrove Bros Ltd"
        Else
        Subject = "Annual Outgoing Reconciliation - " & rs!FullAddress
        Msg = "Dear " & rs!FirstName & ",

" & "The anniversary of the commencement of your lease is the " & rs!StartReviewDate & ", The results show that a sum of " & rs!BalancePayment & "Excl. GST has been overpaid. an you please confirm how you wish for this overpayment to be treated?" & "

" & "Should you have any queries relating to the attached review please do not hesitate to call." & "

" & "Regards" & "

" & "Lovegrove Bros Ltd"
    End If
    
    DoCmd.OutputTo acOutputReport, "OutgoingReviewR", acFormatPDF, CurrentProject.Path & "\OutgoingReview.PDF"
    
    SendEmail Msg, rs!EmailAddress, Subject, False, CurrentProject.Path & "\OutgoingReview.PDF"
      
    Set db = Nothing
    Set rs = Nothing
    
End Sub

Issue is with the SQL statement and in particular the "From" critieria.  Spelling is correct, and I've tried creating another query to target but still doesn't work.  Any suggestions?

Thanks

Alex Hedley  @Reply  
           
4 years ago
Harcode this from
Set rs = db.OpenRecordset("Select * From OutgoingReviewQ where TenantID=" & TenantID)
To
Set rs = db.OpenRecordset("Select * From OutgoingReviewQ where TenantID=1")
Replacing 1 with a known ID.
Does it work?
Alex Hedley  @Reply  
           
4 years ago
Richard can you fix the quotes I broke please?
Richard Rost  @Reply  
           
4 years ago
What did you break?

Also - make sure your query isn't expecting a parameter. Try it with a table if you can.
Warren Lovegrove OP  @Reply  
     
4 years ago
Thanks Guys,

Changing the TenantID to specific ID doesn't change anything.  During debug that part of SQL expression is selecting correct field.
Changing it to target a table allows things to run past that element and get stuck on first rs! field not within that table. Adding parameter within query to target TenantID within that form also results in same error.
Not sure what parameters it may be expecting?
Warren Lovegrove OP  @Reply  
     
4 years ago
Hi again,

I've found a solution to force the issue, as follows:
created a public function as outlined below
Public Function FormFieldValue(ByVal OutgoingReviewF As String, ByVal OutgoingReviewID As String)
    FormFieldValue = Forms(OutgoingReviewF).Controls(OutgoingReviewID)
End Function


Then set parameter within query as below.
FormFieldValue("OutgoingReviewF","OutgoingReviewID")

While this solution works, it does create a run-time error 2450 (can not find referenced form) where opening that query.
If there's a better solution would be great to know it, otherwise I'll run with this.

Thanks

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: 4/30/2026 11:58:59 AM. PLT: 1s