Listbox

r3df1sh

Registered User.
Local time
Yesterday, 20:23
Joined
Sep 8, 2004
Messages
16
I have a Form that contains a Listbox. This listbox is populated with the contents of a table. What I am attempting to do is when a field within the listbox is double-clicked it brings up that record in another form. I have searched various resources and could not find the proper syntax to do this.

I also am looking for a way to refresh the listbox on return from the individual record form. I attempted to use the refresh in the focus settings, however the list box remains unchanged unless I close and reopen the form.

Please forgive the newbishness and thanks for any guidance.
 
VBA coding mate... At least for the refresh.

Design your form, and since you new to it I'll tell ya the bound way - I personnaly don't like the bound way...

for the Source data of the form create a query (use the three dots or create a query and point to that) which has all the fields, and the id field. In this fields criteria, right click and go to the builder. From here select forms, your form and the list box control from the list and then 'boundcolumn'. Click ok. Save the query. Set the textboxes properties>data to the right fields.

On the main form, on the list box, make sure the first column is bound and that it is the id, set the column width of 0 to hide it.


That should cover the opening of the form.
On the popup form, click in the dark grey area to get form properties, change the properties tab to events, and select on_unload. Choose
Code:
. This takes you to the VBA Editor with the appropriate sub filled out for you. Between the .....sub on_unload... and 'end sub' pu the following code (change the name to the form you have called it and the name of the listbox).
[code]
forms("frmnamehere").controls("lstboxcontrolnamehere").requery

Experiment. Good luck post up if it works and what you did. Any problems post up other people have other ways to accomplish this.


Vince
 
Heres the best way to do this:

(1) Create a query with the information you want in the detail information form

(2) Create the form with the recordsource set as the query you created above

(3) In the ID field in the query (the one that is also in the listbox that you will use to create a relationship between the data) put in the criteria:
Code:
Forms!YourListboxFormName!YourListboxName
If you have the linking field located in the listbox somewhere other then the first column use this instead:
Code:
 Forms!YourListboxFormName!YourListboxName.Column(ColumnNumber)

(4) in the Double_Click event put this code:
Code:
Docmd.OpenForm "YourPopUpFormName"

(5) In the On_Close event of the Pop up form put this code:
Code:
 forms!YourListboxFormName!YourListboxFormName.Requery

Thats all there is to it!  :D

HTH,
Kev
 
Thanks for the speedy response. I followed your instructions and it works great!

Thanks again
 

Users who are viewing this thread

Back
Top Bottom