Automatic Requery

Bergja

Registered User.
Local time
Today, 16:38
Joined
Jul 11, 2008
Messages
17
Hello,

I am looking for some help with the following problem. I have a listbox on a form that populates via the following code:

strSQL = "SELECT [Ticket Number], [User Name], [Phone Number DSN], [Computer Name], [Building Number], [Room Number], [Date Problem Started], [Type of Issue], [Status] FROM Helpdesk"

Me.lstTickets.RowSource = strSQL
Me.lstTickets.Requery

This works great however If someone were to add a new entry into the Helpdesk table, the data would not appear on this listbox without another requery. At the moment to mitigate this I am using a "refresh" button that executes the code:

Me.lstTickets.Requery

I would like to know if it is possible to automatically update the listbox whenever changes are made to the helpdesk table, without locking up the form.

Thanks!
 
If you use the "not in list" event to add the new info and handle things properly, the added record should get added automaticaly.

If the data is not added via the NIL event, then yes you need to requery :(
 
I appreciate the quick response!

However,

I am a bit confused, I had never heard of the Not in List event so I did a little research and it seems to me that this is only available as a combo box property. Also, in order to use it you have to set the limit to list property to "yes" However my listbox does not have that. Also, it seems that this is a solution for users who are adding data specifically to a combo box.

Let me explain exactly what is happening with my database:

I have 2 main forms, one called IAHelpdesk and one called IMO. The IAHelpdesk form is part of the front-end deployed to all my users, who use it to put information in the Helpdesk Table. This is a one way transaction, users do not manipulate data in the Helpdesk table only create new records. The IMO form is what I use to view records that have been input into the Helpdesk table. When the IMO form is opened the 1st tab (called Trouble Tickets) shows a large listbox which immediatly pulls specefic data from the Helpdesk table using the code I posted above. This is for two reasons, 1) to show a brief overview of a specific record and 2) it uses the TicketNumber column of the listbox to find the corresponding record (OnClick event) and display it on the 2nd tab.

I am trying to find code that will automatically update the listbox if there are any new records added to the Helpdesk table. or perhaps automatically update at certain intervals such as every 2 minutes.

Thanks
 
You can use the "on timer" event to requery every 2 minutes....
A requery thought leads to loss of "focus" and direction of the list box, usually that is not prefered.
 
Thanks! That did it, exactly what I needed!
 

Users who are viewing this thread

Back
Top Bottom