How do you update a combo box after a record has been added?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have tried to get combo box to update it's list after adding a record to no
avail. It works fine when I close and save the database which sense as the
following query is run when the form loads:

Row Source: SELECT Login.[Primary Key], Login.StudentID FROM Login;

The combo box is unbound as I am not trying to change the data in the record
set. The following is the code that is automatically created when you use the
wizard.


Private Sub Combo63_AfterUpdate()
' Find the record that matches the control.

Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Primary Key] = " & Str(Nz(Me![Combo63], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

End Sub

This al works fine except when I add a new record it does not appear in the
list.

I have tried Combo63.Requery...this only stops the list from having anything
in it at all. I have tried just about everything I can think of but to redo
everything in VB which I don't want to do. Is therte a simple solution to
this problem

Thanks very much,
Glen L. Harvey
 
Are you saying the newly added info is not in the form's recordsource? or
that it is not in the combo box's row source?

Requery is the way to update either of these data sources:

Me.Combo63.Requery ' updates combo box's row source

Me.Requery ' updates form's recordsource
 
Ken:

It does not update the Combo63 control...The studentID does get updated in
the record set which is exactly how it should be..If I re-open the form in
the design mode then re-open it in form mode it updates the combo box
correctly .So I placed the Me.Combo63.Requery in the StudentID Afterupdate
event where I also parse the last studentID entry and add leading zeros if
needed. This does not work either. Where would I place the Me.Combo.requery.

Ken Snell said:
Are you saying the newly added info is not in the form's recordsource? or
that it is not in the combo box's row source?

Requery is the way to update either of these data sources:

Me.Combo63.Requery ' updates combo box's row source

Me.Requery ' updates form's recordsource

--

Ken Snell
<MS ACCESS MVP>

Glen Harvey said:
I have tried to get combo box to update it's list after adding a record to
no
avail. It works fine when I close and save the database which sense as
the
following query is run when the form loads:

Row Source: SELECT Login.[Primary Key], Login.StudentID FROM Login;

The combo box is unbound as I am not trying to change the data in the
record
set. The following is the code that is automatically created when you use
the
wizard.


Private Sub Combo63_AfterUpdate()
' Find the record that matches the control.

Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Primary Key] = " & Str(Nz(Me![Combo63], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

End Sub

This al works fine except when I add a new record it does not appear in
the
list.

I have tried Combo63.Requery...this only stops the list from having
anything
in it at all. I have tried just about everything I can think of but to
redo
everything in VB which I don't want to do. Is therte a simple solution to
this problem

Thanks very much,
Glen L. Harvey
 
Let's start at the beginning. Tell us exactly what you are doing (show
samples of data) when you "add" data, and give the form's RecordSource. I am
not understanding what is being updated, how it's being updated, and so on.
Post the code that runs when you are adding a "new" value.

--

Ken Snell
<MS ACCESS MVP>

Glen Harvey said:
Ken:

It does not update the Combo63 control...The studentID does get updated in
the record set which is exactly how it should be..If I re-open the form in
the design mode then re-open it in form mode it updates the combo box
correctly .So I placed the Me.Combo63.Requery in the StudentID Afterupdate
event where I also parse the last studentID entry and add leading zeros if
needed. This does not work either. Where would I place the
Me.Combo.requery.

Ken Snell said:
Are you saying the newly added info is not in the form's recordsource? or
that it is not in the combo box's row source?

Requery is the way to update either of these data sources:

Me.Combo63.Requery ' updates combo box's row source

Me.Requery ' updates form's recordsource

--

Ken Snell
<MS ACCESS MVP>

Glen Harvey said:
I have tried to get combo box to update it's list after adding a record
to
no
avail. It works fine when I close and save the database which sense as
the
following query is run when the form loads:

Row Source: SELECT Login.[Primary Key], Login.StudentID FROM Login;

The combo box is unbound as I am not trying to change the data in the
record
set. The following is the code that is automatically created when you
use
the
wizard.


Private Sub Combo63_AfterUpdate()
' Find the record that matches the control.

Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Primary Key] = " & Str(Nz(Me![Combo63], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

End Sub

This al works fine except when I add a new record it does not appear in
the
list.

I have tried Combo63.Requery...this only stops the list from having
anything
in it at all. I have tried just about everything I can think of but to
redo
everything in VB which I don't want to do. Is therte a simple solution
to
this problem

Thanks very much,
Glen L. Harvey
 
Back
Top