Choosing several checkboxes

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

Guest

The user types in the destination ID in a prompt box. A form is returned
listing many POs associated with that destination. The user then clicks a
checkbox besides each PO that he wants to see details on. He then clicks on
a command button that opens each of the details he selected. The code below
is displaying one detail record at a time. What do I need to add to the
code so that all the detail records selected with the checkbox will display
in the "frmDisplayDetails".

If Me.SelectRecord = True Then
stDocName = "frmDisplayDetails"

stLinkCriteria = "[IO_PrimaryKey]=" & Me![IO_PrimaryKey]
DoCmd.OpenForm stDocName, , , stLinkCriteria
 
Hi Sharon

I'm assuming that your checkbox must be bound to a yes/no field
(SelectRecord?) in your form's recordsource. This field must be either in
the PO table or in a related table that contains IO_PrimaryKey as a foreign
key.

First, you must include SelectRecord in the recordsource of your
frmDisplayDetails form. (If the selection takes place in a separate,
related table then include that table in your recordsource query.)

Now, change stLinkCriteria to:
stLinkCriteria = "[SelectRecord] <> 0"
 
Great, this code allows the user to select several checkboxes to display
several records. Now, what is the code to clear the checkboxes so I can
choose a different set of records. Right now, I have to exit and re-enter
the form to clear the current record selection even if I uncheck the checkbox.



Graham Mandeno said:
Hi Sharon

I'm assuming that your checkbox must be bound to a yes/no field
(SelectRecord?) in your form's recordsource. This field must be either in
the PO table or in a related table that contains IO_PrimaryKey as a foreign
key.

First, you must include SelectRecord in the recordsource of your
frmDisplayDetails form. (If the selection takes place in a separate,
related table then include that table in your recordsource query.)

Now, change stLinkCriteria to:
stLinkCriteria = "[SelectRecord] <> 0"

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

SharonInGa said:
The user types in the destination ID in a prompt box. A form is returned
listing many POs associated with that destination. The user then clicks a
checkbox besides each PO that he wants to see details on. He then clicks
on
a command button that opens each of the details he selected. The code
below
is displaying one detail record at a time. What do I need to add to the
code so that all the detail records selected with the checkbox will
display
in the "frmDisplayDetails".

If Me.SelectRecord = True Then
stDocName = "frmDisplayDetails"

stLinkCriteria = "[IO_PrimaryKey]=" & Me![IO_PrimaryKey]
DoCmd.OpenForm stDocName, , , stLinkCriteria
 
Hi Sharon

Still assuming the checkbox is bound to a yes/no field:

CurrentDb.Execute "Update [YourTable] set SelectRecord=0;", dbFailOnError

You say the checkboxes are all clear when you open the form. How are you
doing this? you should be able to use the same code to clear them on a
command button click or some-such.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

SharonInGa said:
Great, this code allows the user to select several checkboxes to display
several records. Now, what is the code to clear the checkboxes so I can
choose a different set of records. Right now, I have to exit and
re-enter
the form to clear the current record selection even if I uncheck the
checkbox.



Graham Mandeno said:
Hi Sharon

I'm assuming that your checkbox must be bound to a yes/no field
(SelectRecord?) in your form's recordsource. This field must be either
in
the PO table or in a related table that contains IO_PrimaryKey as a
foreign
key.

First, you must include SelectRecord in the recordsource of your
frmDisplayDetails form. (If the selection takes place in a separate,
related table then include that table in your recordsource query.)

Now, change stLinkCriteria to:
stLinkCriteria = "[SelectRecord] <> 0"

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

SharonInGa said:
The user types in the destination ID in a prompt box. A form is
returned
listing many POs associated with that destination. The user then
clicks a
checkbox besides each PO that he wants to see details on. He then
clicks
on
a command button that opens each of the details he selected. The code
below
is displaying one detail record at a time. What do I need to add to
the
code so that all the detail records selected with the checkbox will
display
in the "frmDisplayDetails".

If Me.SelectRecord = True Then
stDocName = "frmDisplayDetails"

stLinkCriteria = "[IO_PrimaryKey]=" & Me![IO_PrimaryKey]
DoCmd.OpenForm stDocName, , , stLinkCriteria
 
Back
Top