D
Doug
Well, if you changed the code to add records from a command button, per the
instructions I sent, then that would explain why it's not working from the
form's AfterUpdate or AfterInsert event: the form is not inserting the
record; you are, though the code. So the AfterUpdate and AfterInsert events
wouldn't apply.
Just put the combo box requery code at the end of the routine that adds the
new record, and you should be fine.
I tried that, but I don't know how to reference it, and haven't gotten
around to searching Google for that. "Me" is not pointing to the form
in the add record routine. (There is no "Combo36" in the list after
you type "Me." - like there is in the AfterUpdate routine.) I need to
get a basic book on using Access (just systax, I know how to program -
I've also never used VB before). It took me about 30 minutes
searching Google to find how to change a fields value... (you use the
"clone"...) Do you know of a good/short online reference?
Well, it should work. What's the rowsource of your combo box? Please copy
and paste it here exactly.
Row Source Type: Table/Query
Row Source: SELECT [Clients].[ClientID], [Clients].[FirstName],
[Clients].[MiddleName], [Clients].[LastName] FROM Clients;
I am adding records from a control button on the form now.
I tested this again, and now the combo box is updated with
Combo36_gotFocus(). I'd prefer to only update that when necessary,
not every time a new record is selected... I don't know why that
works now. The combo box is still not updated with either
Form_AfterInsert() or Form_AfterUpdate().
(SNIP)
Once I use the combo box to select a record, the record selector count
changes to 1. I can still arrow over to 2 and enter a new record.
When I do that the new record doesn't show up in the combo box list
(the others still do). If I close the form and reopen it, the combo
box sees the new record(s).
Well, as John noted, just requery the combo box when a new record is
inserted (I'd do the After Insert event of the form). Just do:
Me.MyComboBox.Requery
I've put that in three places (below). The only thing that updates the
combo box is closing the form and reopening it.
Private Sub Combo36_GotFocus()
Me.Combo36.Requery
End Sub
Private Sub Form_AfterInsert()
Me.Combo36.Requery
End Sub
Private Sub Form_AfterUpdate()
Me.Combo36.Requery
End Sub
(SNIP)
The above is for if you prompt the user for the PK (customer ID?). If
the
PK
is an autonumber PK, then you'd do this instead:
=========================================
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("MyTable, dbopenDynaset)
rs.AddNew
rs!OtherField = someothervalue 'This is optional.
rs.Update
rs.bookmark = rs.LastModified
Me.Recordsource = "Select * From MyTable Where FieldPK="& rs!FieldPK
rs.close
set rs = nothing
=========================================
That worked. Thanks.
4) While in a code module, go to Tools | References. Uncheck Microsoft
ActiveX Data Objects (if it's checked). If "Microsoft DAO" is not
checked,
then scroll down the list, and check the highest numbered version of it.
And that should do it.
Neil
(SNIP)