listbox extended multiselect & opening form

rew

Registered User.
Local time
Today, 19:40
Joined
Aug 22, 2005
Messages
19
Hi, i was wondering if it's possible in a listbox with the multiselect option set to extended simply click on a field and open a form with the data of this field..

example:
i've a listbox of my customers, (only first and last name)..i click on one of this and a new form with all the details'll open, so i can see and modify stuff...
with the multiselect set to none this works..but with the extended??

(btw..i wanna just click on one filed, but i need the extended multiselection on for other options..)

thx in advance
 
Sure, but you'll need to get the value just as you would for any multiselect purpose (search here for multiselect if you don't already have that code). You may want to test to make sure only one value is selected.
 
Oh, and I'd probably use the double click event, or it will run this when you're clicking on selections for those other purposes.
 
pbaldy said:
Oh, and I'd probably use the double click event, or it will run this when you're clicking on selections for those other purposes.

thx
but after doubleclicking on a field i've a runtime error3075 ..it cant' get the value..i'll search something here as you 've suggested
 
A multiselect listbox will always return null, so you need to use the looping code to get the value, even if only one is selected.
 
rew said:
thx
but after doubleclicking on a field i've a runtime error3075 ..it cant' get the value..i'll search something here as you 've suggested

Would you mind posting your result? This is EXACTLY what I'm looking for...

SHADOW
 
pbaldy said:
A multiselect listbox will always return null, so you need to use the looping code to get the value, even if only one is selected.
honestly i've no idea where to get that code..can you help me please?
 
rew said:
honestly i've no idea where to get that code..can you help me please?

My goal is to be able to double click a row of a multiselect and it will know the ID of the row that was double clicked. Is this even possible in Access...?

SHADOW
 
shadow9449 said:
My goal is to be able to double click a row of a multiselect and it will know the ID of the row that was double clicked. Is this even possible in Access...?

SHADOW
yes, it's possible, but you've to pass the id through a code..because, as pbaldy said, a multiselect always returnes null..so no id
 
rew said:
yes, it's possible, but you've to pass the id through a code..because, as pbaldy said, a multiselect always returnes null..so no id

It's fairly straightforward to loop through the listbox and know which ones are highlighted. What I want to do is have it repond when you double click by opening the form to the appropriate record, as you described.

SHADOW
 
Sounds like you each have half the equation. Rew needs the multiselect code, (which is all over this site) to get the id, Shadow needs to know about the wherecondition argument of OpenForm, which you can use the id with to open a form to the appropriate record.
 
pbaldy said:
Sounds like you each have half the equation. Rew needs the multiselect code, (which is all over this site) to get the id, Shadow needs to know about the wherecondition argument of OpenForm, which you can use the id with to open a form to the appropriate record.

Nope. I know how to open and filter a form. I don't know how to retrieve the ID (just like Rew) and I'm not convinced that the Listbox is aware of which row was double clicked.

Remember, this is a multiselect, so you may have 6 rows highlighted but the user double clicked the fourth row to be highlighted. Not as easy to get that information as it might sound.

SHADOW
 
i've made something like this ..it works,but isn't properly with the multiselect code..

Code:
Private Sub List0_DblClick(Cancel As Integer)

DoCmd.OpenForm "cliente", , q_lettere_inserzioni_internet, "[CLI_ID] = " & Me.List0.Column(0), , acDialog
Me.List0.Requery

End Sub

where List0 is the list, "cliente" the form that i want to open, q_lettere_inserzioni_internet is the query from which the data of the listbox came from, [CLI_ID] is the id, and column(0) is the column of the listbox in which is contained the id..
it seems that it works...
 
rew said:
i've made something like this ..it works,but isn't properly with the multiselect code..

Code:
Private Sub List0_DblClick(Cancel As Integer)

DoCmd.OpenForm "cliente", , q_lettere_inserzioni_internet, "[CLI_ID] = " & Me.List0.Column(0), , acDialog
Me.List0.Requery

End Sub

where List0 is the list, "cliente" the form that i want to open, q_lettere_inserzioni_internet is the query from which the data of the listbox came from, [CLI_ID] is the id, and column(0) is the column of the listbox in which is contained the id..
it seems that it works...

Ok, let me give it a shot and get back...

SHADOW
 
the query is not needed...
i use almost the same code of the non-multiple..except for the column (was like this
Code:
"[CLI_ID] = " & Me.List0
only, now is
Code:
"[CLI_ID] = " & Me.List0.Column(0)
..the "problem" is that i'm not sure why and how it works..:D:D :D
 
rew said:
the query is not needed...
i use almost the same code of the non-multiple..except for the column (was like this
Code:
"[CLI_ID] = " & Me.List0
only, now is
Code:
"[CLI_ID] = " & Me.List0.Column(0)
..the "problem" is that i'm not sure why and how it works..:D:D :D

Ok, works fine. I didn't realize it would pick up that column. I'm good now.

Good luck.

SHADOW
 
..the "problem" is that i'm not sure why and how it works..

The reason it works is that when you have only one value selected, which is what will happen when you double-click on one value, it is taking the value of the first column, which is zero-based, of the current value of the bound field in the listbox (which is the item selected) even though the actual listbox "value" is 0.
 

Users who are viewing this thread

Back
Top Bottom