Results 1 to 3 of 3
  1. #1
    3 Star Lounger MacroAlan's Avatar
    Join Date
    Feb 2003
    Location
    St Louis, Missouri, USA
    Posts
    254
    Thanks
    6
    Thanked 1 Time in 1 Post

    Pass a Value to another Form (XP / SP2)

    I have a form where users are keying weekly time. When they come to someone
    with changes, I want them to click on the button for the maintenance form and
    pass the employee number to the main form. When they come back show update in the original.

    Also, they need to occasionally add new people on the fly, so I will be putting on an additional button to
    pop up a blank form.
    Alan

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Pass a Value to another Form (XP / SP2)

    You can pass an argument to another form by using the OpenArgs argument of DoCmd.OpenForm (it's the last argument). The form that is opened can inspect OpenArgs in its OnLoad or OnOpen event and use it to set the employee number. You'll have to requery the calling form when returning from the popup form. You can check for OpenArgs being Null to avoid errors if you don't pass an employee number.

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Pass a Value to another Form (XP / SP2)

    If the main form the one where the time is being entered? Are you passing a value from it to the maintenance form or from the maintenance for to the main form or something else entirely? Sorry, but I got <img src=/S/confused.gif border=0 alt=confused width=15 height=20> as to which form you were passing a value to. And is the maintenance form (and the main form, for that matter) already open or is it being opened by the button click? If the latter, then Hans' suggestion is the simplest way to make it work. There are more exotic methods that you can use in AXP but there's not point in describing them if the straight-forward approach is most suitable.

    As for updating the original form (is that the same as the main form?) when they come back to it, that too can be handled in several ways. In XP you can create a custom event on the secondary form, or on a subform, for that matter, and have the form raise that event to any class that may be watching for it using the WithEvents keyword. It's a handy trick if you need to get exotic or if you need an immediate response between objects rather than waiting for a form to close, etc.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •