Solved

Invalid procedure call or argument

Posted on 2016-09-30
1
30 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 18

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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 Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now