Combo can't find new record in subform

G

GeoBrooks

Using ACC2000:

In the main form there is an unbound combobox [cbobabyname] used to select
baby records in a subform. If a new baby record is created, the save command
button includes the code to requery the cbo. This works fine. Yet if the
new name is selected the subform opens on the first record in the recordset.
In debug, one can see that the recordcount for the main form recordset has
been incremented, but new record field values are all null. The query on
which the recordset is based will show the correct new values. Performing a
requery on the recordset changes the behavior so that selecting any name
brings up the new record.

cboBabyName_AfterUpdate includes:

Set rs = Me.RecordsetClone
rs.FindFirst "[baby_id] = " & Str(Me![cboBabyName])

If the main form is closed and reopened, all behaves as expected. Surely
there must be a way to get expected results without closing and reopening.

TIA

George
 
G

GeoBrooks

The solution: changing the snippet to read

intBaby = Me![cboBabyName]
Me.Requery
Set rs = Me.RecordsetClone
rs.FindFirst "[baby_id] = " & intBaby


George
 

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