I created form with 4 option button. How can I write click command in build event?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • moepusu
    New Member
    • Oct 2010
    • 10

    I created form with 4 option button. How can I write click command in build event?

    How can I write click command in build event for my form using option button? Here I wrote like that, but when I click option1 it doesn't work. thank you

    Code:
    private Sub Report_Selection_Click()
    
    Select Case Me.Label1
    
    DoCmd.OpenReport "total", acViewDesign
    
    Case Me.label2
    
    MsgBox "The job is done !"
    
    End Select
    End Sub
    Last edited by NeoPa; Oct 28 '10, 10:57 PM. Reason: Please use the [code] tags provided.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32662

    #2
    I'm guessing the confusion is due to difficulties with English. I'm afraid you will need to express your question more clearly though, as currently I can make no sense of it at all.

    Comment

    • colintis
      Contributor
      • Mar 2010
      • 255

      #3
      I'll put my guessing in from what I understand if its true....

      As I can see you giving an event on clicking the COMMAND button. Then your select case on label1 is not opening the report, because the structure is not correct, the select case in here is looking for something to compare with label1 (whatever things inside). The next line case with label2 is telling Access to check if label2's content is the same as label1's content. Therefore, the whole select case is WRONG.

      If you are trying to make selectable options to choose from, you will need to first create an option group, then create option buttons (the circle with a black dot) within the group. And from my guessing, you tried to make selection first with the options, then a command button click event to perform certain things. So after creating the options in the option group PLUS naming correctly, you should have a structure like this
      Code:
      private Sub Report_Selection_Click()
          Select Case <Option group name>.Value
              Case 1    'If option 1 is select
                  DoCmd.OpenReport "total", acViewDesign
              Case 2    'If option 2 is select
                  MsgBox "The job is done !"
          End Select
      End Sub

      Comment

      Working...