Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2011
    Posts
    9

    Unanswered: Userforms, buttons, and requerying

    I have a form used for assigning periodical subscriptions to employees (don't ask.)

    The first field is a combobox with the list of available subscriptions. If the user tries to enter a title that isn't already in the db (a reasonable possibility) it fires a userform that says "you can't enter new titles here, click button 1 to enter a new title, or click button 2 to enter one already in the system." (paraphrasing)

    The button to open the new form works fine, but when the new title is entered and the entry form is closed, the combobox on the original form doesn't have the new entry.

    As I understand it I need to requery the combobox; is there a way to do the requery from another form?

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Yes it's possible ([Application.] is optional):
    Code:
    Application.Forms("<Name of the form with the Combo>").ComboX.Requery
    However, if the second form is modal, which seems logical to me, you can use a simple:
    Code:
    Me.ComboX.Requery
    on the line immediately following the one that opens the second form as execution of code in the first form is suspended while the second (modal) form is open and will only resume when it's closed:
    Code:
    DoCmd.OpenForm "ModalForm", , , , , acDialog ' <-- Execution is stopped 
                                                 '     until "ModalForm" is closed.
    Me.ComboX.Requery
    Have a nice day!

  3. #3
    Join Date
    Mar 2011
    Posts
    9
    That did it! Thanks!

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome!
    Have a nice day!

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
  •