Option buttons

L

Lee

I have a form on which I've placed two option buttons in a
frame. When one option is selected, I want to open a
form, while the second option will run a macro to open
report. The value for optInd is 1 and the value for
optAll is 2. I noticed that VB does not seem to offer a
click event for option buttons, so I added a command
button to the form, and depending on which option is
selected when the button is clicked, that action will be
carried out. This is the code I've written:


Dim Report
Dim stFormInd As String
Dim stRptAll As String
stFormInd = "frmRptSelectIndVendor"
stRptAll = "macContactsByVendor"

If optInd = 1 Then
DoCmd.OpenForm stFormInd, , , stLinkCriteria

ElseIf optAll = 2 Then
DoCmd.RunMacro stRptAll
End If

It's given me error 2427 "You have entered an expression
that has no value."

What am I doing wrong?
 
J

June Macleod

one solution might be to use the OnClick event of the Frame object.

The value of the frame is equal to whichever option button has been
selected.

June Macleod
 
D

Dale Fye

I don't see where you have defined stLinkCriteria that you are using
in your OpenForm method.

The frame also has an AfterUpdate event that will fire as soon as
either of the option buttons is selected. Only problem is that if you
selected "Report" and then want to do it again, clicking on the
"Report" option won't fire the AfterUpdate" event.

--
HTH

Dale Fye


I have a form on which I've placed two option buttons in a
frame. When one option is selected, I want to open a
form, while the second option will run a macro to open
report. The value for optInd is 1 and the value for
optAll is 2. I noticed that VB does not seem to offer a
click event for option buttons, so I added a command
button to the form, and depending on which option is
selected when the button is clicked, that action will be
carried out. This is the code I've written:


Dim Report
Dim stFormInd As String
Dim stRptAll As String
stFormInd = "frmRptSelectIndVendor"
stRptAll = "macContactsByVendor"

If optInd = 1 Then
DoCmd.OpenForm stFormInd, , , stLinkCriteria

ElseIf optAll = 2 Then
DoCmd.RunMacro stRptAll
End If

It's given me error 2427 "You have entered an expression
that has no value."

What am I doing wrong?
 

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