Solved

Invalid procedure call or argument

Posted on 2016-09-30
1
52 Views
Last Modified: 2016-10-04
I have a form with a command button that opens a report.  If I just open the form and make no changes to the data the report opens just fine.  But if I make a change to the data in the form and click the command button to open the report I get an error...  "Invalid procedure call or argument"

Here is the onclick event of the command button.  Any thoughts?

    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

    Dim stDocName As String

    strQD = "" '< clear the variable first
    

    If Me.lstPartNChills.ListCount >= 1 Then
        Dim j
        With lstPartNChills
        For j = 1 To .ListCount - 1
        strQD = strQD & "(" & .Column(1, j) & ") - " & .Column(2, j) & ", "
        Next
        End With
        strQD = Left(strQD, Len(strQD) - 2)
    End If

    stDocName = "rptProcessCard"
    DoCmd.OpenReport stDocName, acPreview
    
    strQD = ""

Open in new window

0
Comment
Question by:SteveL13
1 Comment
 
LVL 19

Accepted Solution

by:
crystal (strive4peace) - Microsoft MVP, Access earned 500 total points
ID: 41823697
instead of: DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
do:
if me.dirty then me.dirty=false

Open in new window

which will save the record only if changes have been made.
For constructing the where clause, use null propogation (+ to concatenate in a comma only if something is already there):
dim vWhere as variant
vWhere = Null

Open in new window

then in the loop:
vWhere  =( vWhere  + ", ") & ...

Open in new window

can you give an example of what you want? I see you are doing math but realize that columns of a list or combo are text and need to be wrapped in a conversion function to get a number.  Or are you trying to get a range of values?

When you open the report, specify the where clause to limit the records
    DoCmd.OpenReport stDocName, acPreview , , vWhere

Open in new window

0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question