Solicit and act on user choice

  • Thread starter Thread starter Rose B
  • Start date Start date
R

Rose B

I am sure that what I am trying to do can be easily achieved...... but I
don't know how and can't find anything by searching - PLEASE HELP!

I have a form where I want the user to be given a choice of options when
they click a button - all the while I only had two choices I used the vbYesNo
MsgBox route - but now I need them to pick 1 from 4. I thought that if I
built a simple form with an option group with the 4 options on, then this
would be OK, but I cannot work out how to pass the user choice back to the
main form (hope that this makes sense).

My ideal solution would be along similar lines to the MsgBox one - but with
4 options, and then I code in VB what needs to happen depending upon which
option the user chose.
 
On Sun, 22 Mar 2009 07:36:09 -0700, Rose B

You can do something very similar to MsgBox. You know MsgBox is modal,
and so should your form be:
DoCmd.OpenForm "myOptionsForm", ...., acDialog

Then when the user clicks an option you write:
Me.Visible = False
This makes the form "fall out of the modal loop" and the statement
after DoCmd.OpenForm runs. That's where you can inspect which option
was chosen:
dim myOption as Integer
myOption = Forms!myOptionsForm!myGroupBox.Value
Then it's safe to close the form:
DoCmd.Close acForm, "myOptionsForm"

Now myOption holds the selected option, and you can proceed.
(change myObjectNames to yours)

-Tom.
Microsoft Access MVP
 
Back
Top