• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 403
  • Last Modified:

Option Group need to make default to not check

Hello, I have an unbound option group (has a radio button) and I need it to default to "not checked" when the form is opened.  It seems to always remeber my last choice and I do not need this.  I have an "On Load" event of the following but it still does not default to not checked.  I triedd "False", "No", -1, 0 but still to no avail.   Any ideas? or does it have to be bound?   thank you
Private Sub Form_Load()
   
    Me.OptionGroupedSynBilat = False
    Me.OptionNotGrouped = False
   
End Sub
0
Petrobras
Asked:
Petrobras
  • 13
  • 11
  • 2
  • +2
2 Solutions
 
IainTheVBALearnerCommented:
Look at the properties of the option group.  Set it's Default Value number to 0 to make it so no option buttons in that group are checked.

Make sure when you add the buttons to the group directly from the Toolbox toolbar - so they're properly associated with each other.
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Try this:

Private Sub Form_Load()
   
    Me.OptionGroupedSynBilat = Null
    Me.OptionNotGrouped = Null
   
End Sub

mx
0
 
PetrobrasAuthor Commented:
Hello Lain, DBmx:  I tried both to no avail.  I set default values to 0 for all option group radio buttons.  I also added tried to Null code.  The form is a pop up and I also tried to put the Null code on "On Open".  The radio buttons still "remember" my last choice  when opening the form.  

any other ideas?  thank you.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
puppydogbuddyCommented:
Hi Petrobras,
Long time no see! Hope everything is going well for you.  
The way I do it is to:
1. place an option button in the location you want to park it
2. set the button's option value to zero and set its visible property set to no.
3. set the default value for the OptionGroup to 0
4.In code, I usually have a select case statement and park at the  0 button after a selection is as shown:
Select Case Me.optGroupName.Value
       Case xxxx

       Case xxxx

End Select
Me.optGroupName = 0
0
 
puppydogbuddyCommented:
Hi Mx,
Good to see you around!

pDog
0
 
IainTheVBALearnerCommented:
Did you add the option group first, then add the button to the group directly from the toolbar?  when you add the button to the group, the backgroud of the group should turn dark.  This way they're properly linked.

Then set the default value of the group to 0 (not the button - the group)

I've tried this and works...I didn't have to write any code - just added the controls the right way and set the goup's properties.
0
 
PetrobrasAuthor Commented:
Hi pdog, good to hear from you again. I am trying to implement your idea but need some extra help.  First of all I want to say that it is not an option "group" but instead option buttons (radio buttons).  Knowing this, your #3:  set the default value for the OptionGroup to 0, I dont think applies.  But what do I know...not much.

I know I said it was an option group and I seem to remember that maybe there is a difference between group and stand alone buttons.  Maybe now since it is know that these are not option "groups" it changes it all.  maybe they should be option groups too but not sure how to make em.  

also, sorry but I am not sure what to put for the "xxx".  

Let me know...pb
0
 
PetrobrasAuthor Commented:
lain, I see your post now.  I will try to add the group...
0
 
PetrobrasAuthor Commented:
RATS!  I made the frame (have not done one in awhile).  But after clciking the option, it says "You entered an expression that has no value".  I followed the wizard in the option group.  
My code below for the frame:  
It is my lamens code and I know there is a better way to do it.  
See any issues here:  (I also tried =1, 0, -1 50, 5million a billion...etc...)  Now, I am just shooting the finger at the computer.  
Private Sub Frame7_Click()
   
    If Me.OptionGroupedSynBilat.Value = True Then
        DoCmd.OpenReport "rptPortfolioBilatSyn", acViewReport, , , acNormal
        Me.Visible = False
    End If
    If Me.OptionNotGrouped.Value = True Then
            DoCmd.OpenReport "rptPortfolio", acViewReport, , , acNormal
            Me.Visible = False
    End If
       
    If Me.OptionUsagePercent.Value = True Then
            DoCmd.OpenReport "rptPortfolioUsageSort", acViewReport, , , acNormal
            Me.Visible = False
    End If
   
End Sub
0
 
puppydogbuddyCommented:
yes, as lain said, you need to add the group and place your buttons inside the group, otherwise the buttons will not work in team fashion.  xxx in the case statement are the different options corresponding to the object of interest in the Select Case statement.  You can have numbers Like Case 1, Case 2, etc. or you can have text like the example below:
 
Select Case Me.OptionColors.Value
Case "Blue"
       Do Something
Case "Yellow"
        Do Something else
End Select
0
 
puppydogbuddyCommented:
Petrobras,
I have to go now, but I wanted to give you an idea of the syntax you can use.  I may have some errors because I did it off the top of my head without looking at anything to check it.

Private Sub Frame7_Click()
Select Case True
         Case 1
                  DoCmd.OpenReport "rptPortfolioBilatSyn", acViewReport, , , acNormal
                  Me.Visible = False
         Case 2
                    DoCmd.OpenReport "rptPortfolio", acViewReport, , , acNormal
                    Me.Visible = False
          Case 3
                    DoCmd.OpenReport "rptPortfolioUsageSort", acViewReport, , , acNormal
                    Me.Visible = False
End Select
     Me.OptionGroupFrame = 0                ' park button at default parking space
0
 
PetrobrasAuthor Commented:
AHH...I see what the case is now.  I will give this a whirl in just a min.  
0
 
calpurniaCommented:
Hmm... would I be right in thinking that the problem occurs not when you open the form, but when you move from record to record? If so, you need to put your code on the OnCurrent event rather than OnLoad.
0
 
PetrobrasAuthor Commented:
Calpurnia,
<the problem occurs not when you open the form, but when you move from record to record?
I do not have code anywhere else but on the
Private Sub Frame7_Click()
Select Case True
         Case 1
...........
I replaced the On load with the Private Sub Frame7_Click()
0
 
calpurniaCommented:
Could you just try putting your original code

    Me.OptionGroupedSynBilat = False
    Me.OptionNotGrouped = False

on the OnCurrent event of the form?
0
 
PetrobrasAuthor Commented:
Calpurnia, and others: SORRY!  I think I had some kind of issue with the internet.  I asked another question but it did not post.  I wrote the question and pressed send but something happened and your last post made me think that we were not on the same page.  

The issue I have now is no matter what radio button I press, only the first report opens in case 1.  The names of the reports are correct so it is not a naming issue.  The values of the option buttons are correct at:  1,2,3.  I will be at the computer for awhile now.  thank you

Private Sub Frame7_Click()
   
 Select Case True
         Case 1
                  DoCmd.OpenReport "rptPortfolioBilatSyn", acViewReport, , , acNormal
                  Me.Visible = False
         Case 2
                  DoCmd.OpenReport "rptPortfolio", acViewReport, , , acNormal
                  Me.Visible = False
         Case 3
                  DoCmd.OpenReport "rptPortfolioUsageSort", acViewReport, , , acNormal
                  Me.Visible = False
End Select
     Me.Frame7 = 0                ' park button at default parking space
End Sub

0
 
puppydogbuddyCommented:
Petrobras,
Just got back.  Have not had a chance to look it up yet..but try :
Case = 1     'use equal sign

or this:
Case Is 1     'use the word "Is"
0
 
PetrobrasAuthor Commented:
puppydog:  I tried case = 1 and case is 1 and still did not correct the report opening to only case 1 issue.
(Access automatically changes Case is 1 to Case is = 1)
any other ideas?
0
 
puppydogbuddyCommented:
Try it this way:
Private Sub Frame7_Click()
Dim iRpt As integer   '<<<<<<<<<<<<<<dim a variable
 Select Case True
         Case iRpt = 1             '<<<<use it in the expression

         Case iRpt = 2
----------------------------------
if "=" does not work, use "Is ="
0
 
PetrobrasAuthor Commented:
puppydog:  Hmmm...that did not work either.  Actually, after making that change rt above, I could not click a radio button at all.  There was no action at all and no report opening.

what next?
0
 
puppydogbuddyCommented:
change: Select Case True

To:
Select Case iRpt.Value
0
 
PetrobrasAuthor Commented:
When I debug, I get an invalid qualifier error and it highlights the iRpt
this is how I have it:
Option Compare Database
Private Sub Frame7_Click()
   
Dim iRpt As Integer   '<<<<<<<<<<<<<<dim a variable
 Select Case iRpt.Value
         Case iRpt = 1
                  DoCmd.OpenReport "rptPortfolioBilatSyn", acViewReport, , , acNormal
                  Me.Visible = False
         Case iRpt = 2
                  DoCmd.OpenReport "rptPortfolio", acViewReport, , , acNormal
                  Me.Visible = False
         Case iRpt = 3
                  DoCmd.OpenReport "rptPortfolioUsageSort", acViewReport, , , acNormal
                  Me.Visible = False
End Select
     Me.Frame7 = 0                ' park button at default parking space
End Sub

0
 
puppydogbuddyCommented:
I think I know what the problem is: you need to reference your optionframe 7 name, not iRpt

Select Case True
           Frame7 =  1
0
 
PetrobrasAuthor Commented:
It now gives an error of "Statements and labels invalid between Select Case and first case"
0
 
puppydogbuddyCommented:
Select Case iRpt.Value
         Case iRpt = 1
                  DoCmd.OpenReport "rptPortfolioBilatSyn", acViewReport, , , acNormal
                  Me.Visible = False
         Case iRpt = 2
                  DoCmd.OpenReport "rptPortfolio", acViewReport, , , acNormal
                  Me.Visible = False
         Case iRpt = 3
                  DoCmd.OpenReport "rptPortfolioUsageSort", acViewReport, , , acNormal
                  Me.Visible = False
End Select
     Me.Frame7 = 0                ' park button at default parking space
End Sub
Select Case True    <<<<<<<<or:  Frame7.Value
         Case Frame7 = 1
                  DoCmd.OpenReport "rptPortfolioBilatSyn", acViewReport, , , acNormal
                  Me.Visible = False
         Case Frame7 = 2
                  DoCmd.OpenReport "rptPortfolio", acViewReport, , , acNormal
                  Me.Visible = False
         Case Frame7 = 3
                  DoCmd.OpenReport "rptPortfolioUsageSort", acViewReport, , , acNormal
                  Me.Visible = False
          Case Else
                   MsgBox "No such selection."
End Select
     Me.Frame7 = 0                ' park button at default parking space
End Sub
0
 
PetrobrasAuthor Commented:
and highlights Frame7 in Frame7 = 1
0
 
puppydogbuddyCommented:
is Frame7 the name of your option group?
Change :
Select Case True   >>>>>  Select Case Frame7.Value
0
 
PetrobrasAuthor Commented:
that was it!  Worked perfectly.  thank you so much.  
0
 
puppydogbuddyCommented:
Petrobras,
Glad we got it sorted out.  I just plum forgot about the button connection.....sorry!  Thanks for your patience, and the points and grade.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 13
  • 11
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now