By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,110 Members | 1,010 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,110 IT Pros & Developers. It's quick & easy.

Option Group with literal argument

P: n/a

I have 4 option groups with the same choices in each group so I want to
create a module with a public function that would be activated on_click
event.
Public Function OptionSelection(varOption As Variant)

Select Case Forms!frmRecruitment!varOption.Value
Case 1
Forms!frmRecruitment!varOption.Value = 1
Case 2
Forms!frmRecruitment.varOption.Value = 2
Case 3
Forms!frmRecruitment.varOption.Value = 5
End Select
If Forms!frmRecruitment.varOption.Value = 5 Then
Forms!frmRecruitment.strRemarks.SetFocus
End If

End Function
I get a run-time error 2465
Microsoft Access can't find the field "varOption" referred to in your
expression. Can someone please tell me what is wrong with this code?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
What are you passing: the name of the option group, or a reference to it?

If the name, use Forms!frmRecruitment.Controls(varOption).Value (and pass it
as a string, not a variant)

If a reference to the control, use varOption.Value (and change the
declaration from varOption As Variant to varOption As Control)
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(No private e-mails, please)

"margamo" <an*******@devdex.com> wrote in message
news:40*********************@news.frii.net...

I have 4 option groups with the same choices in each group so I want to
create a module with a public function that would be activated on_click
event.
Public Function OptionSelection(varOption As Variant)

Select Case Forms!frmRecruitment!varOption.Value
Case 1
Forms!frmRecruitment!varOption.Value = 1
Case 2
Forms!frmRecruitment.varOption.Value = 2
Case 3
Forms!frmRecruitment.varOption.Value = 5
End Select
If Forms!frmRecruitment.varOption.Value = 5 Then
Forms!frmRecruitment.strRemarks.SetFocus
End If

End Function
I get a run-time error 2465
Microsoft Access can't find the field "varOption" referred to in your
expression. Can someone please tell me what is wrong with this code?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #2

P: n/a
Thanks a lot I was confused about the difference between passing the
name or the value. I wanted to pass the name. Your input was very
helpful.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.