After New Record is added, update search combo box

P

Presto

My main form is named TaskScreen_Main and have2 search combo boxes named
cboSelect and cboSelectCID. The cbo's are in the "header" part of the form.

I use a pop up form to add the record: pop_NewMemberDataEntry. after I
close this form, I need the cboSelect and the cboSelectCID to requery and
have
the new member's name / CID on the lists so I can go on to do more work to
their records.

How do I reference the main form to do this? I have tried it a few different
ways and am running out of patience.
=====================
Private Sub Form_Close()

'WHAT GOES HERE?'

End Sub
 
B

Beetle

Private Sub Form_Close()

Forms!TaskScreen_Main!cboSelect.Requery
Forms!TaskScreen_Main!cboSelectCID.Requery

End Sub
 
T

Tony Toews [MVP]

Presto said:
My main form is named TaskScreen_Main and have2 search combo boxes named
cboSelect and cboSelectCID. The cbo's are in the "header" part of the form.

I use a pop up form to add the record: pop_NewMemberDataEntry. after I
close this form, I need the cboSelect and the cboSelectCID to requery and
have
the new member's name / CID on the lists so I can go on to do more work to
their records.

How do I reference the main form to do this? I have tried it a few different
ways and am running out of patience.
=====================
Private Sub Form_Close()

forms!<form name>!<control name>.requery.

If the form or control name contain only letters or numbers then
remove the <>. If the names contain spaces or characters other than
alphabetic then replace the said:

Tony
 
P

Presto

Yeah, I tried that already and it didn't work.
I added a bogus record for Mr. DELETE ME and it shows up in the tables, but
the combo boxes do not update.
I also tried the following code on the TaskScreen_Main OnFocus event with no
luck :

Private Sub Form_GotFocus()
Me.cboSelect.Requery
Me.cboSelectCID.Requery
Me.cboSelect.SetFocus
End Sub

So, any other suggestions?
 
P

Presto

would I need to use brackets if the form name contains an underscore?
Like this? : Forms![TaskScreen_Main]!cboSelect.Requery
 
P

Presto

Problem solved. The data on the main form was not being refreshed... the
code below does everything I need.
Thanks for the help guys!!


Private Sub Form_Close()
' requeries the source data for the entire main form
' and makes darn sure the search boxes get updated too

Forms![TaskScreen_Main].Requery
Forms![TaskScreen_Main]!cboSelect.Requery
Forms![TaskScreen_Main]!cboSelectCID.Requery

End Sub

<3 Presto.


Presto said:
would I need to use brackets if the form name contains an underscore?
Like this? : Forms![TaskScreen_Main]!cboSelect.Requery



Tony Toews said:
forms!<form name>!<control name>.requery.

If the form or control name contain only letters or numbers then
remove the <>. If the names contain spaces or characters other than


Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Granite Fleet Manager http://www.granitefleet.com/
 
T

Tony Toews [MVP]

Presto said:
would I need to use brackets if the form name contains an underscore?
Like this? : Forms![TaskScreen_Main]!cboSelect.Requery

You've got it working but my response would've been try it and see
what happens.

Tony
 

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