User Input in OnLoad Form Event

K

KaiRich

Hi JN,

This shouldn't be too difficult.
This is the path I would follow:
you have your form, it loads with a combo with values,
this sounds like it is working. The next step then is to
add either an event after a selection is made from the
combo, or an event when the user clicks the button to move
on after they have made a selection from the combo. Now
you have a new form which loads with only the selected
value - I do this a lot in one of my current databases.
The second form holds data fed from a query, this
populates the list boxes (not text boxes) and they are
requeried on load - i.e. the form has the event Form_Load
(), in which there is the line(s) lstBox.Requery, the list
box's data row source is set to the query.

The secret is the query, it has a criteria that reads your
first form's combo box, e.g.:
[Forms]![frmOne]![cboSelection].[Value]
Remember to turn on 'view totals' and set the
query's 'total' to 'Where' (the 'Show' should
automatically uncheck, which is what you want).
(I am assuming you will create this query in design view,
not in SQL view.)

So, you have two forms and one query.
The first form has a combo.
The second form loads from the query.
The query reads from the first form.
The list boxes in the second form requery on load.

You need code in either the change event for the combo or
the click event for the done/next/okay button on the first
form. e.g.
Private Sub cboSelection_Change()
DoCmd.OpenForm "frmTwo"
DoCmd.Close acForm, "frmOne"
End Sub

You need some code in the second form's load event, e.g.
Private Sub Form_Load()
lstBox.Requery
End Sub
Make sure that in the form's design view you select the
list box, look at its properties, events tab, and set the
load event to [Event Procedure]. Otherwise your Form_Load
() code won't be run.

If you have other items to load into the second form which
are dictated by the selection made from the first form,
just include these fields in the query, and have list
boxes for them on the second form. Then set the list
boxes' data to the query, but use the correct bound
column. If this is too hard, then just use another query,
the same as the one you already have. Either way have the
list boxes all requery on load.

I hope this helps,
Kai
-----Original Message-----
Hello,

I have a form that uses a table to display records. The
form needs to ask the user to select a value from a given
Combo Box, which obviously is populated from the form's
record source table. Basically, OnLoad the form will pop
us a combo box with list of items for the user to select
from then open the form with only the value supplied by
the user using that combo box. Is this possible? I know I
can use a parameter query, but that will require a user to
type the full item description and I don't want that.
There are too many items to remember so the user just
needs to be given a list of items from which he/she can
select one to view its related data in the form view. Is
this possible in a form (VBA)? How? Or can an Access query
(SQL) do this?
 

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