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

    Requery sub form based on combo box option


    Hi,

    I have a database which contains user contact information. I have a form where a user can press a button to bring them to a form which allows them to view any other user's contact information. When the button is pressed, a pop-up form appears prompting the user to select a name from the drop down box. The user would select a name from the combo box, hit ok and it should bring up the main contact information form which populates with the chosen user's information. For example, let's say John Doe is using the database. He wants to look up Jane Doe's contact information. He presses the button to initiate the search which brings up the selection pop-up form. John selects Jane Doe from the combo box and presses ok. The form should then open the contact information form and requery the form to populate with Jane's information. Right now the issue that I am having is that the form will not requery to the selected user's information. The sample code I am using on the ok button is as follows
    Code:
    Private Sub cmdUserSelectGO_Click()
    'opens user information form to queried to selected user's information
    If IsNull(cmbUserSelect) Then
        MsgBox ("Please select aname from drop down box")
    Else
        DoCmd.OpenForm"frmUserInfo"
        Me.frmUserInfo.Form.Requery
    End If
    
    End Sub
    What i can't figure out is why the code I am using will not requery to the selected person's information. As I mentioned previously, this sample piece of code is attached to the ok button the pop-up form under the on click event.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    So use the WHERE CONDITION argument of OpenForm.

    DoCmd.OpenForm "frmUserInfo", , , "UserID=" & Me.cmbUserSelect


    Why don't you build a search form that has the search inputs and data on the same form? Review https://stackoverflow.com/questions/...using-openargs
    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.

  3. #3
    enginerdUNH is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Location
    United States
    Posts
    35
    Quote Originally Posted by June7 View Post
    So use the WHERE CONDITION argument of OpenForm.

    DoCmd.OpenForm "frmUserInfo", , , "UserID=" & Me.cmbUserSelect


    Why don't you build a search form that has the search inputs and data on the same form? Review https://stackoverflow.com/questions/...using-openargs
    Thank you June for your response. The error that I am getting with your solution is that the drop down box is based on a query which contains the user ID, user first name and user last name to populate the list of names. I am getting an error of "Syntax error (comma) in query expression 'UserID=Doe, Jane'." when i hit the ok button. Not sure how I correct this issue.

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

Similar Threads

  1. Requery Combo Box from another form issue.
    By Mouse51180 in forum Forms
    Replies: 6
    Last Post: 03-29-2017, 06:29 AM
  2. Requery Combo Box from second form
    By blueman in forum Forms
    Replies: 14
    Last Post: 11-16-2015, 12:03 PM
  3. Combo Box Wizard does not have option form option
    By CementCarver in forum Forms
    Replies: 5
    Last Post: 02-28-2013, 08:54 PM
  4. Run report based on Option and Combo Boxs
    By AussieGal in forum Access
    Replies: 3
    Last Post: 02-20-2013, 08:24 PM
  5. Replies: 1
    Last Post: 03-26-2010, 10:32 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