Results 1 to 9 of 9
  1. #1
    NotaryEtc is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    22

    Have to close out form then reopen for new data to appear in combobox

    Hello all,



    You all have been very helpful, so hopefully you can help me with this.

    I have a button on one of my forms that opens to my customer form, and here I can add new customers. Problem is, once I save the record....The only way I can see the new customer listed in the combobox is by closing the form and reopening it. Is there anything that can be done to fix this?

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    You could requery the combo box in its Got Focus event. Something like:
    Me.ActiveControl.Requery
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by Bob Fitz View Post
    You could requery the combo box in its Got Focus event. Something like:
    Me.ActiveControl.Requery
    The combo box has a row source which can be requiried. Before you close the form, run code that lets you requery the other form if it is open.

    I use

    If CurrentProject.AllForms("YourFormName").IsLoaded Then
    Forms!YourFormName!ComboBoxControl.Requery
    End If

  4. #4
    NotaryEtc is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    22
    Thanks but when it comes to codes, I have no experience! Here are the names of my forms/tables....Maybe you can give me a code to copy and paste then tell me where to put it?

    The name of the form the button is located on is called MotorVehicleJF. This form is a based on a junction table, and is being used as a subform. The combo box located on this form this holding the customer first and last name (and I guess customerid as well)

    When you click the "Add New Customer" button from the MotorVehicleJF......the customer form, called CustomerF will open up. Here I can add a new customer.

    Now I need this new customer to automatically show up in the combo box on the MotorVehicleJF without me having to close and reopen the form.

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Can you show us the code relate to the Click event?

    Go to form design view. Put the cursor on the Add New Customer button, right click, show properties; event Procedure.

    Please copy the code and paste it in your post.

  6. #6
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    The second form CustomerF has properties

    Some of these properties are events, there is a close event for CustomerF

    When you add the code into the event, when you close the form, it fires off the event.

    The code I provided below works like this


    If something is true/false then

    do this

    end if



    That's a basic IF statement.

    So using that if statement I put the method CurrentProject.AllForms().isloaded

    This particular method (or function) gives a true or false.

    The reason I did this first, if I fire off code and the form isn't open then it crashes, so that is why I use the IF statement.

    then to requery use


    Forms!YourFormName!ComboBoxControl.Requery


    and finally it it with end if

    now when the form closes, you get the combo box requiered.

    Simply replace YourFormName with the name of the form the control is on as well as ComboBoxControl with the name of your control (which is MotorVehicleJF according to you)

  7. #7
    NotaryEtc is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    22
    this is what it says on the line in the property sheet....[Embedded Macro]

    When I click on the 3 little dots, it opens a new window that says

    Open Form

    Form Name CustomerF

    View Form

    Filter Name

    Where Condition

    Data Mode

    Window Mode Normal

    Then what appears to be a combobox with the words "add new action" inside...

  8. #8
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by NotaryEtc View Post
    this is what it says on the line in the property sheet....[Embedded Macro]

    When I click on the 3 little dots, it opens a new window that says

    Open Form

    Form Name CustomerF

    View Form

    Filter Name

    Where Condition

    Data Mode

    Window Mode Normal

    Then what appears to be a combobox with the words "add new action" inside...

    That's a macro, that is not using VBA. I think it's third option form the popup when you hit the event property, if you see the window of the macro again go back a step and see again.

  9. #9
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496

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

Similar Threads

  1. Anchoring controls on a form reset on reopen
    By bayners123 in forum Forms
    Replies: 8
    Last Post: 04-13-2014, 10:03 AM
  2. Replies: 4
    Last Post: 09-16-2013, 05:55 AM
  3. Replies: 3
    Last Post: 04-09-2013, 01:35 PM
  4. Replies: 4
    Last Post: 01-18-2013, 02:41 PM
  5. If no matches Reopen form after Msgbox
    By LoveLearning in forum Access
    Replies: 2
    Last Post: 07-18-2012, 06:08 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