Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

listbox.Requery?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
OS:Windows 98SE,Access 2000.
I have two .mdb files. .mdb #1 has data, and .mdb #2 has forms, reports, and one local table. I have a good ADODB connection to both .mdb files, and the apropriate recordsets. I can populating the local table(tmpDevices) in .mdb #2 fine. However I am unable to easily display it in a listbox. Following Code:
'-------------Begin code---------
Private Sub Form_Load()
lstDevices.RowSourceType = "Table/Query"
lstDevices.RowSource = "tmpDevices"
lstDevices.Requery
End Sub
'---------End Code--------
I know for a fact that the data is in the table before this runs. The problem is that it does not show the contents of lstDevices until I unload, and reload the form.
P.S. I also have code that adds items to the local table "tmpDevices", The problem is that when the first device is added, and I requery, I get nothing, however after the first entry it seems to work fine. I have decided to solve my first problem, with the hope that it gives a solution to the other.

Any Ideas?


 
This is just a hunch, but it may be that the list box isn't actually empty at all. I'm sure it's a bug, but sometimes it seems like Access displays text with the foreground color the same as the background color. I've had text boxes do this, so they look empty, but if I click in them I get a selection (not a cursor), and if I copy the selection and paste it in Notepad, I can read it!

This seems to happen only when I change the value of a control from within an event where Access is also attempting to change its value. Something goes wrong with the internal sequence of events. I can typically solve it by moving my code to a different event.

You can test this out by opening your form, then using the Locals pane to examine the list box's ListCount property. If it's not 0, then there really is data in the list, even if you can't see it.

In the example you've given, you could have just set the Row Source Type and Row Source properties in the properties sheet in Design View, though I imagine this example is a simplification and your property settings are conditional. It might work for you to move your logic into the Form_Current event procedure, though. Rick Sprague
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top