Solved

Option Group need to make default to not check

Posted on 2008-10-25
29
372 Views
Last Modified: 2013-11-28
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
Comment
Question by:Petrobras
  • 13
  • 11
  • 2
  • +2
29 Comments
 
LVL 3

Expert Comment

by:IainTheVBALearner
ID: 22805054
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
 
LVL 75
ID: 22805066
Try this:

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

mx
0
 

Author Comment

by:Petrobras
ID: 22805139
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
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 22805150
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
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 22805169
Hi Mx,
Good to see you around!

pDog
0
 
LVL 3

Assisted Solution

by:IainTheVBALearner
IainTheVBALearner earned 100 total points
ID: 22805207
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
 

Author Comment

by:Petrobras
ID: 22805235
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
 

Author Comment

by:Petrobras
ID: 22805245
lain, I see your post now.  I will try to add the group...
0
 

Author Comment

by:Petrobras
ID: 22805303
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
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 22805307
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
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 22805344
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
 

Author Comment

by:Petrobras
ID: 22805392
AHH...I see what the case is now.  I will give this a whirl in just a min.  
0
 
LVL 10

Expert Comment

by:calpurnia
ID: 22805445
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
 

Author Comment

by:Petrobras
ID: 22805488
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 10

Expert Comment

by:calpurnia
ID: 22805550
Could you just try putting your original code

    Me.OptionGroupedSynBilat = False
    Me.OptionNotGrouped = False

on the OnCurrent event of the form?
0
 

Author Comment

by:Petrobras
ID: 22805637
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
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 22805915
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
 

Author Comment

by:Petrobras
ID: 22805931
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
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 22805988
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
 

Author Comment

by:Petrobras
ID: 22806006
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
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 22806012
change: Select Case True

To:
Select Case iRpt.Value
0
 

Author Comment

by:Petrobras
ID: 22806030
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
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 22806032
I think I know what the problem is: you need to reference your optionframe 7 name, not iRpt

Select Case True
           Frame7 =  1
0
 

Author Comment

by:Petrobras
ID: 22806048
It now gives an error of "Statements and labels invalid between Select Case and first case"
0
 
LVL 38

Accepted Solution

by:
puppydogbuddy earned 400 total points
ID: 22806051
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
 

Author Comment

by:Petrobras
ID: 22806054
and highlights Frame7 in Frame7 = 1
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 22806061
is Frame7 the name of your option group?
Change :
Select Case True   >>>>>  Select Case Frame7.Value
0
 

Author Comment

by:Petrobras
ID: 22806064
that was it!  Worked perfectly.  thank you so much.  
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 22806116
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now