requery combo box in subform

G

Guest

Have a form with a subform containing a combo box. If the value entered is
not in the table behind the combo box the user is prompted to enter new
values. If Yes then a new form is opened and the new values are entered into
the table via the form. When the form is closed and you are returned to the
origional form the combo box does not show the new values entered. I have
tried the requery method in a number of events on different forms but am not
abole to find a solution. Please help.
 
G

Guest

On the After update event of the second form or the UnLoad event, try and run
the requery

Forms![Form1Name]![Combo Name].Requery
 
G

Guest

Tries this and get:

Error 2118
You must save the current field before you run the requery action

Ofer said:
On the After update event of the second form or the UnLoad event, try and run
the requery

Forms![Form1Name]![Combo Name].Requery

--
\\// Live Long and Prosper \\//
BS"D


scotbcb said:
Have a form with a subform containing a combo box. If the value entered is
not in the table behind the combo box the user is prompted to enter new
values. If Yes then a new form is opened and the new values are entered into
the table via the form. When the form is closed and you are returned to the
origional form the combo box does not show the new values entered. I have
tried the requery method in a number of events on different forms but am not
abole to find a solution. Please help.
 
G

Guest

Then try and run this line of code before, to save the record

DoCmd.RunCommand acCmdSaveRecord

--
\\// Live Long and Prosper \\//
BS"D


scotbcb said:
Tries this and get:

Error 2118
You must save the current field before you run the requery action

Ofer said:
On the After update event of the second form or the UnLoad event, try and run
the requery

Forms![Form1Name]![Combo Name].Requery

--
\\// Live Long and Prosper \\//
BS"D


scotbcb said:
Have a form with a subform containing a combo box. If the value entered is
not in the table behind the combo box the user is prompted to enter new
values. If Yes then a new form is opened and the new values are entered into
the table via the form. When the form is closed and you are returned to the
origional form the combo box does not show the new values entered. I have
tried the requery method in a number of events on different forms but am not
abole to find a solution. Please help.
 
G

Guest

Still getting same error is the issue because I have the combo boxes in
subforms on the main form?

Ofer said:
Then try and run this line of code before, to save the record

DoCmd.RunCommand acCmdSaveRecord

--
\\// Live Long and Prosper \\//
BS"D


scotbcb said:
Tries this and get:

Error 2118
You must save the current field before you run the requery action

Ofer said:
On the After update event of the second form or the UnLoad event, try and run
the requery

Forms![Form1Name]![Combo Name].Requery

--
\\// Live Long and Prosper \\//
BS"D


:

Have a form with a subform containing a combo box. If the value entered is
not in the table behind the combo box the user is prompted to enter new
values. If Yes then a new form is opened and the new values are entered into
the table via the form. When the form is closed and you are returned to the
origional form the combo box does not show the new values entered. I have
tried the requery method in a number of events on different forms but am not
abole to find a solution. Please help.
 
B

Brian Bastl

You need to set the "Response". Your code should look something like this:

Private Sub Whatever_NotInList(NewData As String, Response As Integer)

if msgbox ("bla bla bla", vbYesNo) = vbYes then
Docmd.Openform "YourForm",,,, acFormAdd, acDialog, NewData
Response = acDataErrAdded 'combo automatically requeried
else
Response = acDataErrContinue
me.undo
end if

End Sub

HTH,
Brian
 
G

Guest

I am having same problem trying to add an entry to a combo list from a
NotInList event procedure. While I thing the responders are right that
acDataErrAdded will requery, I wonder if that only works if the update is
made within the event proc. -- not if the update is made partly by the event
proc (NewData) and also partly by opening up a new form. I.e. my addition
needs several fields filled in, while only one of course kicks off the
NotInList. Is there a way to do this?
 
K

Ken Snell \(MVP\)

Works either way, but be sure that you open the second form in Dialog mode
so that the code pauses until the second form is closed. In fact, it's
usually better to save the data to the table in the second form, do the
requery there, and then close the second form.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top