Solved

Invalid procedure call or argument

Posted on 2016-09-30
1
59 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 20

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Familiarize people with the process of utilizing SQL Server functions 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 Microsoft Ac…
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 …

710 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