Requerying ListBox after linked table changed

  • Thread starter Thread starter Robert
  • Start date Start date
R

Robert

Hi I'm trying to update an Access list box after the table
it is linked to has changed with the following VB code
attached to a command button :

Private Sub cmdAdd_location_Click()

Set dbsDB1 = OpenDatabase("c:\DB1.mdb")
Set rstLocation = _
dbsDB1.OpenRecordset("tblLocation", dbOpenTable)

rstLocation.AddNew
txtLocation.SetFocus
rstLocation.Location_name = txtLocation.Text
rstLocation.Update
rstLocation.Close

lstLocation_name.Requery
End Sub

The first time I click the command button the table
updates but not the list box. If I click the command
button a second time the list box updates and shows both
new records from the table. After this the update seems to
work ok i.e. the problem seems to be the first update only.

- any ideas ?
 
Howard, thanks for the input - but the table updates fine
with this code - the problem seems to be the List Box
requery doesn't work the first time. Any ideas on the list
box would be appreciated ... cheers, Robert
 
Back
Top