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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simulate a click event in a listbox

Status
Not open for further replies.

Guiderman

MIS
Jan 16, 2003
12
0
0
CA
Hi gang!

I have a search function in my app that populates a listbox. Normally the list box is filled when the form is opened then the user clicks on one item and it displays info about that item in a subform.

Now I want the search function to essentially find that item and display the info in the subform. Right now, all I've been able to do is highlight the item to be clicked by using Me.Item.Selected(0) = True

I tried putting the code from the onClick event into the search routine, but that didn't work.

Thanks for any help.
 
change the recordsource of the subform to
forms!mainform!form!subform.recordsource = dlookup("field", "tablename", "fieldname = ' " & me.listboxname & "'")
using the after update event of the listbox.

It will automatically requery the subform

Ian Mayor (UK)
Program Error
Always make your words sweet and nice. Because you never know when you may have to eat them.
 
How are ya Guiderman . . .

A starting point:
Code:
[blue]   Me.[purple][b][i]ListboxName[/i][/b][/purple].Selected(0) = True
   Call [purple][b][i]ListboxName[/i][/b][/purple]_Click[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
I'm getting closer to getting this resolved, but not yet. I've moved the click event as suggested by Ace, but now I have a new problem. The listbox isn't being populated with any values. You can see the items on the screen, but when you check a value, it's null.

I put a break in the code and in the Immediate window and
query the value of Me!Item.Column(2) and the result is null.

I need to figure out either what is wrong with my listbox.
 
In the immediate window I'd query the value of Me!Item.RowSource

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top