Combo Box Question

S

Steph

I have a form (AddInsertionOrder) that allows a user to
create a new insertion orders. It is connected to the
InsertionOrders table. One of the fields requires the
user to enter the name of a billable client. I have set
up a combo box to list existing Billable Client names from
another table, BillableClients. If the user does not see
the client they need on that list, I have added a button
to the AddInsertionOrder form that, when the user clicks
on it, it opens a form allowing them to add a new billable
client. This form (AddBillClient) is connected to the
BillableClients table. The user fills out the Billable
Client name, address, phone, etc. and saves the new
billable client info in the BillableClients table.

Here's my problem: Once they save that new Billable
Client, and they go back to the AddInsertionOrder form,
the new Billable Client name does not show up on the combo
box list. Help!

Thanks in advance, Steph
 
C

chriske911

you have to let the combobox refresh it's datasource with the requery method
easiest way is to let the form to enter a new billable client pop up on the
"not in list" event for that combobox and then after closing the billable
client form requery the combobox

bon chance
 
S

Steph

Thanks...it worked like a charm.

-----Original Message-----


You need to requery the combo box after the client has been added.
There are two ways you could go about this; either should work.

Method 1: Change the command button's code to open form AddBillClient
in dialog mode, then add a line afterward to requery the combo box. For
example (just guessing at names for the button and the combo box):

Private Sub cmdAddClient_Click()

DoCmd.OpenForm "AddBillClient", _
WindowMode:=acDialog

Me.cboClient.Requery

End Sub

You'd need to replace my guessed-at names for objects with your real
names.

----------------------

Method 2: Add code to the Close event of form AddBillClient that
requeries the combo box on form AddInsertionOrder if it's open. The
code might look like this:

Private Sub Form_Close()

On Error Resume Next ' ignore error
Forms!AddInsertionOrder!cboClient.Requery

End Sub

Again, you'd need to replace my guessed-at names for the combo box with
the real name.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


.
 

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