Update form with newly added data

T

Tara

I have a form (frmCustomers) with a combo box. I have code in the combo
box's Not In List event that opens a form (frmAddCustomer) so users can add
new data. What I'd like to have happen is for the data in frmCustomers to
update to the newly added data as soon as frmAddCustomer closes.

Any help is appreciated!
 
K

Klatuu

Without seeing the code in your Not In List event, I can't be specific;
however, there are two things you have to do.

First, to get the newly added record into your form's recordset, you have to
requery the form. When that is done it will, of course, cause the first
record in the form's recordset to become the current record.

To make then newly added record the current record, you have to move to it
in your record source. The NewData argument in the Not In List event is
very handy for this. Use a FindFirst on the field where you store the
NewData value:

With Me.RecordsetClone
.FindFirst "[MyFieldName] = """ & NewData & """"
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With

The above assumes MyFieldName is a text data type
 

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

Similar Threads


Top