Requerying Data in Combo box after adding a new record (1 Viewer)

GoodyGoody

Registered User.
Local time
Today, 09:10
Joined
Aug 31, 2019
Messages
120
HI,

I have a subform where users select a runner and post a time against the runner. If the runner is not in the Runner drop down I allow the user to add a new runner and return to the subform entry. I want the list now to contain the new record added but whatever I do the drop down list is only refreshed when the user goes to the next new line. I've tried all the events but none seem to requery the Runner box. Is this possible to do? BTW, I have put a Requery on the Macro that runs the AddNewRunner form before it returns to the subform I just left to add the new record. Thanks in advance. Stephen
 

CJ_London

Super Moderator
Staff member
Local time
Today, 09:10
Joined
Feb 19, 2013
Messages
16,610
what have you actually tried? Usual method is to just requery the combo control.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 16:10
Joined
May 7, 2009
Messages
19,241
add code on the Close event of AddNewRunner form:
Code:
Private Sub Form_Close()
[Forms]!MainFormName!subFormNameOfRunner.Form!runnerComboboxName.Requery
End Sub
 

GoodyGoody

Registered User.
Local time
Today, 09:10
Joined
Aug 31, 2019
Messages
120
Hi, Yes I'm requerying the combo box. I'm actioning the AddNew record by the OnNotInList event for the combo box. I successfully add the new record and in the same macro, requery the Combo box (I tried all the other Events such as OnDirty, OnChange etc but just got errors or the same result). But when I return to the same line on the subform (remember the cursor is still in the Combo box so hasn't lost focus I don't think as far as the form is concerned) despite deleting part of the name which previously didn't exist and caused the correct AddNew runner behaviour, it still doesn't requery the combo. I seem to only be able to get it to requery the Combo by exiting the combo completely and returning to it. Hmmm...
 

moke123

AWF VIP
Local time
Today, 04:10
Joined
Jan 11, 2013
Messages
3,920
What code are you using in the not in list event?
Are you setting the response to acDataErrAdded?
 

GoodyGoody

Registered User.
Local time
Today, 09:10
Joined
Aug 31, 2019
Messages
120
I'm using the Embedded Macro to first add the new runner and then requery the combo box on the subform before returning to it.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 01:10
Joined
Oct 29, 2018
Messages
21,471
I'm using the Embedded Macro to first add the new runner and then requery the combo box on the subform before returning to it.

Can you post the code you’re using please? Thanks!
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 16:10
Joined
May 7, 2009
Messages
19,241
macro has limited use.
you need vba to put the new data in the combo.
Code:
Private Sub Area_NotInList(NewData As String, Response As Integer)
docmd.OpenForm FormName:="AddNewRunner",DataMode:=acFormAdd,WindowMode:=acDialog,OpenArgs:=NewData
Response = acDataErrAdded
End Sub

now form AddNewRunner must accept the parameter that is passed to it.
on AddNewRunner Load Event:
Code:
Private Sub Form_Load()
Me.txtRunner = Me.OpenArgs
End Sub
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 01:10
Joined
Aug 30, 2003
Messages
36,125
FYI I moved your thread out of the introductions forum. Welcome to AWF.
 

Users who are viewing this thread

Top Bottom