Results 1 to 5 of 5
  1. #1
    neill_long is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jun 2018
    Posts
    9

    Check Box selected to carry out multiple functions: prin a couple of forms and update fields

    I have an option on my form that the user ticks a check box if something has been sent to our finance department. Just now there is an event procedure on this check box as follows:



    Click image for larger version. 

Name:	check36.jpg 
Views:	24 
Size:	36.0 KB 
ID:	34720

    I have a button that will print out a couple of reports, which there is an embedded macro attached to it, as follows:

    Click image for larger version. 

Name:	embedded macro.png 
Views:	24 
Size:	96.2 KB 
ID:	34721

    What I would like to try to achieve is get rid of the button and when the user selects the check box, it will:

    1. Add the date to the Date_to_Finance field
    2. Print the reports, as shown in the picture above.

    I have replicated the macro and saved it as FinanceForms. In the event procedure I added:

    Private Sub Check36_Click()
    DoCmd.RunMacro "FinanceForms"
    End Sub

    But the form then displayed errors in some fields:

    #Name?


    I'm guessing what I did is confusing the database and that's why I get the errors. Am I doing something wrong or can someone suggest a different approach, possibly adding code that will do what I am wanting it to do instead of using a macro?

    thanks
    Alistair

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    You want all fields in the query,
    dont use references to form fields in the report,
    use them in the query, the report looks at query fields,to stop #name.

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    The code to replicate the macro would use

    DoCmd.OpenReport

    with the appropriate arguments. Add that to your code.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    neill_long is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jun 2018
    Posts
    9
    I have kind of got this working, thanks for the responses. It is now printing the reports when I click the checkbox. However it is also printing a copy of the form the checkbox is on. Here is what I have on my code, how would I amend it so that it only prints the report?

    Code:
    Private Sub Check36_Click()
    If Me.Check36 = True Then
            Me.Refresh
        Me.Date_to_Finance = Date
        DoCmd.OpenReport "Sales Invoice Request", acViewNormal
        DoCmd.PrintOut , , , , 1
        DoCmd.OpenReport "Finance Duplicate", acViewNormal
        DoCmd.PrintOut , , , , 1
       
     Else
            Me.Date_to_Finance = Null
        End If
    End Sub

    thanks
    Alistair

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    Get rid of the printout lines.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 06-08-2018, 09:01 AM
  2. Replies: 18
    Last Post: 10-29-2017, 06:19 PM
  3. Replies: 4
    Last Post: 05-08-2012, 10:04 AM
  4. Replies: 0
    Last Post: 01-03-2011, 03:38 PM
  5. Replies: 1
    Last Post: 01-22-2008, 03:36 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums