Requerry a combo box after adding a record to its source table

V

Veli Izzet

Hi all,

I have a combo box (limited to list) combo1 where I choose the
customers for filling out an order. Combo is bound to the tblCustomers
table. Ocasionally, the customer is a first-time customer, so I have to
go the customers form to input the data tofor that customer.

For this, I have a command button cmdNewCust on frmOrders which opens
frmCustomers.

After inputting data in the frmCustomers, I have to exit and reopen
frmOrders so that the new added customer will show in the combobox.

How can I add an instruction to the onclick event of the cmdNewCust so
that the the combobox will be requerried.

The code on the cmdNewCust is (Onclick)

stDocName = "frmCustomers"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec

Thanks for answers,
 
G

Guest

In the New Customer form try

Me.Refresh

On lost focus or after update event
It works for me just fine but:

a) I'm new to access
b) I'm no expert

I think where you have considered the code will not work because you need to
refresh after you have entered all the details not on opening the new
customer form

My Code is as follows

Private Sub AddMarketCompanyButton_Click()
On Error GoTo Err_AddMarketCompanyButton_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Frm_Add_New_Marketing_Company"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord acForm, "Frm_Add_New_Marketing_Company", acNewRec
Me.Refresh
Exit_AddMarketCompanyButton_Click:
Exit Sub

Err_AddMarketCompanyButton_Click:
MsgBox Err.Description
Resume Exit_AddMarketCompanyButton_Click

End Sub

:
 
G

Guest

Hi Veli,

Instead of using a command button to open frmCustomers, you can use the
NotInList event procedure of the combo box to open this form. The user would
simply type the name into the combo box. When they hit the enter key, this
event procedure will fire if the value they entered is not in the list. You
can find an example here:

Not In List - Detailed Instructions by Tom Wickerath
http://www.datadynamicsnw.com/accesssig/downloads.htm


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

:

Hi all,

I have a combo box (limited to list) combo1 where I choose the
customers for filling out an order. Combo is bound to the tblCustomers
table. Ocasionally, the customer is a first-time customer, so I have to
go the customers form to input the data tofor that customer.

For this, I have a command button cmdNewCust on frmOrders which opens
frmCustomers.

After inputting data in the frmCustomers, I have to exit and reopen
frmOrders so that the new added customer will show in the combobox.

How can I add an instruction to the onclick event of the cmdNewCust so
that the the combobox will be requerried.

The code on the cmdNewCust is (Onclick)

stDocName = "frmCustomers"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec

Thanks for answers,
 

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