Results 1 to 7 of 7
  1. #1
    enginerdUNH is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Location
    United States
    Posts
    35

    open form based on button selected

    Hi,

    I have a database with a few different forms. One form displays a user's contact information, and another 3 display a selected user's training information, schedule, or certifications. I have a form where the user can press one of four buttons specifying if they want to view another user's contact information, training, schedule, or certifications. When any of the buttons are pressed, I have a pop-up form which prompts the user to select the person whose information they want to view. What I am wondering is if it is possible to use the same pop-up form regardless of the command button pressed to select the user's name rather than having to have a separate pop-up form for each command button. What I envision is the following: John Doe wants to view Jane Doe's contact information. He presses the contact information command button and the pop-up form appears prompting him to select Jane Doe's name. He selects her name and presses ok and the contact information form appears. On the flipside, Joe Smith wants to view Simon Cowell's schedule. Joe presses the schedule button and the SAME pop-up form appears prompting him to select the desired user name. Joe select's Simon's name and presses ok and the schedule form pops up. I don't know if this is possible and i imagine that it would take some sort of if statement on the on click event but i am unsure of how to incorporate this. If this isn't something i am able to do, I will make separate pop-up forms for each command button but of course this is not the ideal option.
    Last edited by enginerdUNH; 02-27-2018 at 04:41 AM.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    why wouldnt you just have 1 form, with all info on it.
    1 continuous form of all contacts, enter name in the text box on the header,
    the list filters down, select the record wanted, click Detail button to show the 1 record.
    docmd.openform 'frmDetail",,,"[id]=" & txtID

    the single record form opens showing detail,
    there can be a tab control to see the subform.
    click any tab to see training, schedule, or whatever.

    all data 1 form, 1 subform

  3. #3
    enginerdUNH is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Location
    United States
    Posts
    35
    Quote Originally Posted by ranman256 View Post
    why wouldnt you just have 1 form, with all info on it.
    1 continuous form of all contacts, enter name in the text box on the header,
    the list filters down, select the record wanted, click Detail button to show the 1 record.
    docmd.openform 'frmDetail",,,"[id]=" & txtID

    the single record form opens showing detail,
    there can be a tab control to see the subform.
    click any tab to see training, schedule, or whatever.

    all data 1 form, 1 subform
    I understand what you're saying however I don't want there to be only one form which displays all information. There is a lot of information and i cannot be displayed all on one form which is why i have it broken up into individual ones. Also, when a user is trying to look up certain information, like training, schedule or certifications, I want this to be user friendly and not have the user have to go to the contact information form first just to access the training form when they can just access it directly. As it is, the contact information form is already a tabbed form. Like i said in my first post, I want to have the correct form pop up based on the button pressed and filtered based on the name selected in the subsequent pop-up form. If this is not possible with one pop-up form and some sort of code to differentiate between which button was pressed to bring up that form (as with an if statement or similar coding) I will just create multiple pop-up forms that perform the same function but this is not ideal.

  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
    You can use the OpenArgs argument of OpenForm to pass the name of the form to be opened, and then use that in the popup form.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    enginerdUNH is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Location
    United States
    Posts
    35
    Quote Originally Posted by pbaldy View Post
    You can use the OpenArgs argument of OpenForm to pass the name of the form to be opened, and then use that in the popup form.
    Thanks pbaldy for your response. Just a few questions here. I know what you mean by using OpenArgs to pass the name of the form but I'm wondering where to implement this. Do i do it on the menu form before the pop-up form even comes up or do i do it on the pop-up form after the ok button is pressed? if it is on the menu form, how will the pop-up form know which form to pass the information to when the ok button is pressed? if it is on the pop-up form, how do i get it to decide which form it goes to based on the button pressed on the menu form?

  6. #6
    enginerdUNH is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Location
    United States
    Posts
    35
    Shortly after i replied I thought of a way I could make it work and I wanted to see if you guys agree. I can add an unbound field to the form which will populate the name "contact info", "training", "schedule", or "certifications". I can then put an if then statement on the ok button of the pop-up form that will open the correct form based on the value populated in the unbound box. and then bring up the record from there.

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    That can work, maybe not as clean as OpenArgs. I remembered this:

    http://www.baldyweb.com/WrappedForm.htm
    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: 16
    Last Post: 04-19-2016, 09:28 PM
  2. Button open selected record in subform table, in new form
    By BrainExplodingFromCoffee in forum Forms
    Replies: 4
    Last Post: 04-12-2016, 02:19 PM
  3. Replies: 10
    Last Post: 03-31-2015, 12:14 PM
  4. Replies: 2
    Last Post: 04-01-2013, 04:23 PM
  5. Replies: 7
    Last Post: 05-01-2012, 11:43 AM

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