selection of db record from list box and form transfer

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

simple stuff here, haven't been a programmer in about 15 years (things have
changed a bit). created a form "switchboard" with a listbox that queries two
fields from one "data" table (ID# & Company Name). I want the user to be
able to select from the listbox a particular company name and (i) highlight
on a single click and (ii) using company name (not showing ID# in list box)
jump to another existing "Input" form that contains all of the data from the
"Data" table.

where i am thus far...list box shows all companies correctly in alpha order,
single click does not do anything (can't figure out on click highlighting),
double click opens the "Input" form correctly but i can only get it to open a
specific record I identify in the code, i.e. DoCmd.OpenForm "Input", , ,
"Data.ID=8". Thoughts?
 
You got it about right.

First here is to build the listbox, but make the FIRST column the "id" (we
call this the primary key id). Make the 2nd column the company as you have.
The listbox wizard will NORMALLY hide the primary key for you. (if it does
not, then during the wizard process, simply re-size the first column so you
can't see it). This will result in a listbox that DISPLAYS the company name,
but when you reference the listbox, it will return the id (this is exactly
what we want).


Then, your code in the click event which you have is 99% correct. it should
read:

DoCmd.OpenForm "Input", , , "ID = " & me!MylistBox


note how the above expression will actually result in is a expresison of

"ID = 53223"

Also, you might want to use the double-click..as the click event might be a
bit too agressive, and a user just clicking on any entry will launch a form.

For some more ideas on "listbox" and pick lists..take a quick view of the
follwing screen shots..as they will give you some more ideas:

http://www.members.shaw.ca/AlbertKallal/Articles/Grid.htm
 
Back
Top