Results 1 to 6 of 6
  1. #1
    terry6582 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Dec 2017
    Location
    TN
    Posts
    21

    Need help with VBA code.

    Have a form with a field named vendor that is set as a yes/no check box. Need vba to make a decision based on checked or not checked. If it is checked it needs to open a macro "vendor form" that opens and displays a vendor form. If it is not check it needs to open a macro "switchboard entry" that will display a menu screen.

    if [attendee.vendor] =-1 then goto sub macro [vendor form]
    else if [attendor.vendor] =0 then go to sub macro [switchboard entry]
    endif



    or could it be written to open the form "vendor pre-reg" directly.

    OK, I need a vba expert to give the the VBA code to make this work.
    '
    Thanks you

    Baldcamper

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,398
    I don't use macros but not sure what the issue is. at its simplest, code would be

    Code:
    if [attendee.vendor] then docmd.runmacro "vendor form" else docmd.runmacro "switchboard entry"

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Do these macros do anything else than just open a form?

    Of course the VBA can open appropriate form. Here is a one-liner:

    DoCmd.OpenForm IIf(Me.Vendor, "vendor pre-reg", "switchboard entry")

    Now what event do you want to execute this code from - a button Click?


    Advise not to uses spaces nor punctuation/special characters (underscore only exception) in naming convention.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    terry6582 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Dec 2017
    Location
    TN
    Posts
    21
    Sorry Ajax and vip,

    These do work since they do not look at the yes/no condition of vendor. It's condition is -1 for yes and 0 for no. Maybe it would work if the conditions for vendor were dim'd to true/false?

    Baldcamper

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Did you mean "These do not work …"?

    Either expression should work. Did you actually try them?

    Code looks at Vendor field/control. If the field is True then the expression returns the True result and If False returns the False result.

    If it makes it easier for you to understand, then use:

    DoCmd.OpenForm IIf(Me.Vendor = True, "vendor pre-reg", "switchboard entry")
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    terry6582 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Dec 2017
    Location
    TN
    Posts
    21
    Sorry June 7 that does not work either. Maybe I need to better describe what I am trying to do. Will revisit when I get time.

    Thanks

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

Similar Threads

  1. Replies: 20
    Last Post: 10-13-2015, 09:05 AM
  2. Replies: 3
    Last Post: 10-16-2014, 08:49 AM
  3. Replies: 2
    Last Post: 06-28-2013, 12:58 PM
  4. Replies: 7
    Last Post: 05-28-2013, 09:11 AM
  5. Replies: 1
    Last Post: 05-04-2013, 12:19 PM

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