Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   Seminars   Templates   TechHelp   Fast Tips   Forums   Help   Contact   Join   Order   Logon  
 
Home > Help > AccessDev.NET >
AccessDev.NET AccessDev.NET


Back to AccessDev.NET
 

RunTime Error 3061 Upload Images   Link  
Warren Lovegrove 
27 days 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
27 days 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
27 days ago
Richard can you fix the quotes I broke please?
Richard Rost
27 days 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
26 days 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
24 days 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
Add a ReplyUpload an Image


Back to AccessDev.NET Comments
 

Start a NEW Conversation
 
Only students may post right now. Click here for more information on how you can set up an account. If you are a student, please LOG ON first.
 
Subscribe
 

Check out these other pages that may be of interest to you:

9/27/2022Report Border
9/26/2022First Day of Month
9/23/2022Before Update
9/22/2022Synchronize Subforms
9/21/2022InputBox
9/20/2022Link Master Fields
9/19/2022DateSerial
9/18/2022Sequential Annual Coding
9/16/2022Scope
9/15/2022Resize Forms
 
 
The following is a paid advertisement banner. They are used to support the site.
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
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
amicron@gmail.com
Blog RSS Feed    Twitter

YouTube Channel    LinkedIn