Pop up form when item double clicked in a ListBox (1 Viewer)

Jab331

Registered User.
Local time
Today, 14:29
Joined
Sep 25, 2018
Messages
15
Hi all,

Very new to access so i apologise in advance if i ask stupid questions.

I am creating a database and have managed to create a form with a search bar that then populates a listbox below the search bar as a query searches the database table. What i would now like to do is allow the user to double click on any of the items returned in the search and a form would pop up containing even more information regarding the item they have clicked.

For example the database is for mould tools and as tool numbers are searched the only info shown in the listbox is customer, location etc. I would like to allow people to then double click the tool they require and see all of the other tool information stored in the table.

I can attach the database if that helps people.

Thanks in advance.

Jack
 

isladogs

MVP / VIP
Local time
Today, 14:29
Joined
Jan 14, 2017
Messages
18,186
Surely you would do that by selecting an item from the listbox.
This could then open a form or make a subform visible filtered to details of the selected item
 

Jab331

Registered User.
Local time
Today, 14:29
Joined
Sep 25, 2018
Messages
15
Surely you would do that by selecting an item from the listbox.
This could then open a form or make a subform visible filtered to details of the selected item

This is exactly what i'm trying to do. Double click the item in the listbox and then get the further information from there.
 

isladogs

MVP / VIP
Local time
Today, 14:29
Joined
Jan 14, 2017
Messages
18,186
You need at least two columns in the listbox.
Unique ID field (hidden) and your Tool description field.

Add code to the listbox after update event or possibly the double click event.
If you want to open a form, use code similar to

Code:
DoCmd.OpenForm "YourFormName",,,"IDField =" & Me.ListboxName

Obviously change names as appropriate.
The code assumes the ID field is a number.
 

Jab331

Registered User.
Local time
Today, 14:29
Joined
Sep 25, 2018
Messages
15
You need at least two columns in the listbox.
Unique ID field (hidden) and your Tool description field.

Add code to the listbox after update event or possibly the double click event.
If you want to open a form, use code similar to

Code:
DoCmd.OpenForm "YourFormName",,,"IDField =" & Me.ListboxName

Obviously change names as appropriate.
The code assumes the ID field is a number.

Thanks for the reply but i am a genuine amateur when it comes to access. I guess i need to create the form id like to pop up before adding this code, how do i ensure the information shown in the form is the information for the item that has been double clicked?

Sorry for asking the basic stuff but you've got to start somewhere i guess.
 

isladogs

MVP / VIP
Local time
Today, 14:29
Joined
Jan 14, 2017
Messages
18,186
Thanks for the reply but i am a genuine amateur when it comes to access. I guess i need to create the form id like to pop up before adding this code, how do i ensure the information shown in the form is the information for the item that has been double clicked?

Sorry for asking the basic stuff but you've got to start somewhere i guess.

OK. First create the form to show the tool details you want to see. Do this as a 'single form' layout with one record (tool) visible at a time. If opened directly, you would be able to move from one record to the next using the built in form navigation buttons

The code I suggested is then used to filter the form so it opens at the selected record.
 
Last edited:

Jab331

Registered User.
Local time
Today, 14:29
Joined
Sep 25, 2018
Messages
15
OK. First create the form to show the tool details you want to see. Do this as a 'single form' layout with one record (tool) visible at a time. If opened directly, you would be able to move from one record to the next using the built in form navigation buttons

The code I suggested is then used to filter the form so it opens at the selected record.

Okay, i think i am getting there slowly, i have added the code to the listbox so that it opens the new form when double clicked. i am now struggling to get the correct information in this form, how would i set the form up to show the information from the table without one record at a time?
 

isladogs

MVP / VIP
Local time
Today, 14:29
Joined
Jan 14, 2017
Messages
18,186
Not quite sure what you are asking.

There are three main types of form layout
Single - one record shown at a time
Continuous - all records displayed with one record on each 'row'
Datasheet - similar to continuous but looks like a table.

From your original description you want a single form which is filtered to show the item selected in the listbox
 

Jab331

Registered User.
Local time
Today, 14:29
Joined
Sep 25, 2018
Messages
15
Not quite sure what you are asking.

There are three main types of form layout
Single - one record shown at a time
Continuous - all records displayed with one record on each 'row'
Datasheet - similar to continuous but looks like a table.

From your original description you want a single form which is filtered to show the item selected in the listbox

Sorry i misunderstood what you meant earlier, i now have a singe form showing information for each record. Now when i double click a result in the listbox i get a pop up telling me to enter parameter values for ID field and Tool number? rather than the information for the record.
 

isladogs

MVP / VIP
Local time
Today, 14:29
Joined
Jan 14, 2017
Messages
18,186
See my suggested code in post 4.

Good luck.
I have to go out for several hours but if you need more help hopefully someone else will step in.
 

Jab331

Registered User.
Local time
Today, 14:29
Joined
Sep 25, 2018
Messages
15
I'm still getting the enter parameter box rather than the record information when i double click.

Thank you for all your help so far!
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:29
Joined
May 7, 2009
Messages
19,169
chk the pop up if the recordsource is based on parameter query.
if not chk the control source of each textbox.
 

Gasman

Enthusiastic Amateur
Local time
Today, 14:29
Joined
Sep 21, 2011
Messages
14,044
That probably means your variable names are incorrect.?

Colin directed you to open the form with criteria using the ID from the listbox and advised you to change his names to match what you are using.


I'm still getting the enter parameter box rather than the record information when i double click.

Thank you for all your help so far!
 

Jab331

Registered User.
Local time
Today, 14:29
Joined
Sep 25, 2018
Messages
15
I changed the names of the listbox and the form but i did not change the "IDField =" portion of the code, could this be causing the issue?
 

Gasman

Enthusiastic Amateur
Local time
Today, 14:29
Joined
Sep 21, 2011
Messages
14,044
Yes, that needs to be the name of the ID field in your source for the form
 

Jab331

Registered User.
Local time
Today, 14:29
Joined
Sep 25, 2018
Messages
15
Can i just change it to one of the headers from the list box? For example if i change the code to "Tool Number =" will that filter on the selected tool number?
 

Jab331

Registered User.
Local time
Today, 14:29
Joined
Sep 25, 2018
Messages
15
I think i have solved it!

I realised that the query was searching int he first column so i need the ID column to be in that position. That seems to have resolved it.

Thank you for the help everybody!

I'm sure i will be back for many more questions though.
 

Users who are viewing this thread

Top Bottom