Results 1 to 4 of 4
  1. #1
    Jessica240 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    95

    Pretty simple problem: just need a macro to open a form

    Hello everyone. This is a pretty simple problem, but I can't seem to find a solution due to my beginner status.



    I have a form that has a button that runs a macro that opens a report. It works great; however, I want to adjust the macro by including an If statement. Normally that is no problem. But in this case it is problematic because I want the If statement to be based off of a query (Query1). My query will always only have one row of data with one field called "ER_Pay_Schedule". This field will say "YES" or be null - depending on what the user selects on the form.

    The If statement looks like this: [Query1]![ER_PAY_SCHEDULE]="YES"

    When I try to run it, I get this error message:

    "The object doesn't contain the Automation object 'Query1.'
    You tried to run a Visual Basic procedure to set a property or method for an object. However, the component doesn't make the property or method available for Automation operations.
    Check the component's documentation for information on the properties and methods it makes available for Automation operations."

    Basically I just want to set it up so that when the user clicks the button one of 2 things will happen depending on what pay schedule the employee is on. Our employees can only be on one of two pay schedules. The user selects the employee name from the combo box on the form. A different query (EMP_SELECTED) uses the combo box as the criteria for the report.

    BUT if the employee is on the ER PAY SCHEDULE they will get REPORTA. If the employee is on the REGULAR PAY SCHEDULE they will get REPORTB.

    I have included a picture of the macro that is embedded into my button.
    Click image for larger version. 

Name:	IF.JPG 
Views:	15 
Size:	20.0 KB 
ID:	20916
    Thanks in advance for the help!!!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You can't get the value from the query that way. Try a DLookup(), presuming the query returns a single record.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Jessica240 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    95
    Thank you. That is exactly what I needed. You are my hero!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help!
    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: 1
    Last Post: 10-16-2013, 09:19 AM
  2. Replies: 2
    Last Post: 10-09-2013, 05:45 PM
  3. Replies: 3
    Last Post: 03-30-2012, 02:02 PM
  4. simple form problem
    By kcsun in forum Forms
    Replies: 0
    Last Post: 08-12-2010, 12:28 AM
  5. Pretty Form Header - What is it?
    By trb5016 in forum Forms
    Replies: 3
    Last Post: 06-21-2010, 08:58 AM

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