ListBox/Query/Mouseclick Select/Open Form - Getting closer...

G

Guest

created a form "Switchboard" with a listbox that queries a table named
"Detail" pulling two fields, ID (primary key) and Company Name. The listbox
does not show the primary key, only the company name. Would like the user(s)
to select a company from the listbox and (i) highlight the selected company
on a single click and (ii) using ID or Company Name jump to another existing
form "Input" that contains all of the data from the "Detail" table. Where i
stand thus far...

Single click does nothing - first record in listbox remains highlighted no
matter which company you single click on (haven't been able to find/create
appropriate code in Click)

Double click opens the "Input" form correctly but only opens the first
highlighted record in the list box. Current code in Dblclick:

Dim stDocName As String
stDocName = "Input"
DoCmd.OpenForm stDocName, , , "ID = " & ID.Value

Help!
 
G

Guest

I do this often by setting the recordsource of the recieving form in the
onopen event.
I use the docmd.openform method but tend to pass the key value as a opening
argument: (use with the Onclick event of your listbox.)
DoCmd.OpenForm "Input", , , ,acFormEdit, , Me.ID

this opens your form to the current record in edit mode

The recordsource of the Input form is set on the onopen event and looks like:
rs as string
rs = "Select * From TableName Where KeyId = " & me.openargs
me.recordsource = rs

It also sounds like perhaps your initiating form is set to not allow edits.
This will not let you select different items in your listbox control.

Hope this helps.
 
A

adsl

Neil said:
I do this often by setting the recordsource of the recieving form in the
onopen event.
I use the docmd.openform method but tend to pass the key value as a
opening
argument: (use with the Onclick event of your listbox.)
DoCmd.OpenForm "Input", , , ,acFormEdit, , Me.ID

this opens your form to the current record in edit mode

The recordsource of the Input form is set on the onopen event and looks
like:
rs as string
rs = "Select * From TableName Where KeyId = " & me.openargs
me.recordsource = rs

It also sounds like perhaps your initiating form is set to not allow
edits.
This will not let you select different items in your listbox control.

Hope this helps.
 
A

adsl

Neil said:
I do this often by setting the recordsource of the recieving form in the
onopen event.
I use the docmd.openform method but tend to pass the key value as a
opening
argument: (use with the Onclick event of your listbox.)
DoCmd.OpenForm "Input", , , ,acFormEdit, , Me.ID

this opens your form to the current record in edit mode

The recordsource of the Input form is set on the onopen event and looks
like:
rs as string
rs = "Select * From TableName Where KeyId = " & me.openargs
me.recordsource = rs

It also sounds like perhaps your initiating form is set to not allow
edits.
This will not let you select different items in your listbox control.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top