Results 1 to 12 of 12
  1. #1
    luckydead is offline Novice
    Windows 10 Office 365
    Join Date
    Nov 2020
    Posts
    25

    Radio Buttons Problem

    Hello i'm having problem with radio buttons.



    I have added from Option Group wizzard, my radio buttons, named them correctly.
    And i want to make an check when press the button, if no radio button was selected to show message please select button first.

    But i have a problem with error message: you entered an expression that has no value

    Click image for larger version. 

Name:	Capture.PNG 
Views:	12 
Size:	4.6 KB 
ID:	45395

  2. #2
    Minty is online now VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,158
    And what was you code generating the error?

    Also consider giving the option group a default value, then there can never be case when one isn't selected.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    luckydead is offline Novice
    Windows 10 Office 365
    Join Date
    Nov 2020
    Posts
    25
    When i click on each radio button i have values like 1,2,3,4,5,so one to the end radio button
    Click image for larger version. 

Name:	Capture3.PNG 
Views:	11 
Size:	2.7 KB 
ID:	45396

    in my code of button is like this:
    Code:
    Private Sub Command21_Click()
    On Error GoTo Err_Command21_Click
    
    Err_Command21_Click:
        MsgBox Err.Description
        Resume Exit_Command21_Click
        
    End Sub
    And here it shows this error message: you entered an expression that has no value

    Also in Frame41 in properties i set up default value to 1:
    and still shows the same error message:
    Click image for larger version. 

Name:	Capture4.PNG 
Views:	11 
Size:	4.9 KB 
ID:	45397

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,569
    You do not have a label called ?
    Exit_Command21_Click

    Why have you even got that event code, it does nothing?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    Minty is online now VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,158
    That code doesn't do anything?
    Assuming Command21_Click is the button you are clicking to do something then you would need code along the lines of;

    Code:
    Private Sub Command21_Click()
    
         Msgbox "My option group value is " &  NZ(Me.Frame41, "Null Value") 
    
        
    End Sub
    Does that make sense?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  6. #6
    luckydead is offline Novice
    Windows 10 Office 365
    Join Date
    Nov 2020
    Posts
    25
    full code of button:
    Code:
    Private Sub Command21_Click()
    On Error GoTo Err_Command21_Click
    
    
    If Text19.value = "" Then
    MsgBox "Please fill number of copies"
    End If
    
    
    Dim result As Integer
    
    
    If Check_Print = True Then
    result = 1
    End If
        
        If line1_chk.value = -1 Then
        CheckTable ("W177-L")
         If showme = 1 Then
          MsgBox "Result is: " & showme
            'DoCmd.OpenReport "Print_W177-L", acViewPreview
            'If result = 1 Then
            'DoCmd.PrintOut , , , , Text19.Value, False
            'End If
          Else
          MsgBox "Result is: " & showme
         End If
        End If
        
        If line2_chk = True Then
            DoCmd.OpenReport "Print_H247-L", acViewPreview
            If result = 1 Then
            DoCmd.PrintOut , , , , Text19.value, False
            End If
        End If
        
        If line3_chk = True Then
            DoCmd.OpenReport "Print_W177-R", acViewPreview
            If result = 1 Then
            DoCmd.PrintOut , , , , Text19.value, False
            End If
        End If
        
        If line4_chk = True Then
        'Lets check combined Lines shitss pff..
        If MsgBox("Click Yes for V177-L or No for W177-L !", vbYesNo + vbQuestion) = vbYes Then
        DoCmd.OpenReport "Print_V177-L", acViewPreview
        Else
        DoCmd.OpenReport "Print_W177-L", acViewPreview
        End If
        'end this shit...
            If result = 1 Then
            DoCmd.PrintOut , , , , Text19.value, False
            End If
        End If
        
        If line5_chk = True Then
            DoCmd.OpenReport "Print_W247-L", acViewPreview
            If result = 1 Then
            DoCmd.PrintOut , , , , Text19.value, False
            End If
        End If
        
        If line6_chk = True Then
            DoCmd.OpenReport "Print_H243-L", acViewPreview
            If result = 1 Then
            DoCmd.PrintOut , , , , Text19.value, False
            End If
        End If
        
        If line7_chk = True Then
        'Lets check combined Lines shitss pff..
        If MsgBox("Click Yes for H247-R or No for W247-B !", vbYesNo + vbQuestion) = vbYes Then
        DoCmd.OpenReport "Print_H247-R", acViewPreview
        Else
        DoCmd.OpenReport "Print_W247-R", acViewPreview
        End If
        'end this shit...
            If result = 1 Then
            DoCmd.PrintOut , , , , Text19.value, False
            End If
        End If
        
        If line8_chk = True Then
        'Lets check combined Lines shitss pff..
        If MsgBox("Click Yes for H243-R or No for V177-R !", vbYesNo + vbQuestion) = vbYes Then
        DoCmd.OpenReport "Print_H243-R", acViewPreview
        Else
        DoCmd.OpenReport "Print_V177-R", acViewPreview
        End If
            'end this shit...
            If result = 1 Then
            DoCmd.PrintOut , , , , Text19.value, False
            End If
        End If
    
    
    Exit_Command21_Click:
        Exit Sub
    
    
    Err_Command21_Click:
        MsgBox Err.Description
        Resume Exit_Command21_Click
        
    End Sub

  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,569
    So walk through the code line by line to see where the error occurs. As the code looks copied, if on first radio button, likely on others?

  8. #8
    luckydead is offline Novice
    Windows 10 Office 365
    Join Date
    Nov 2020
    Posts
    25
    even if i do it like this same error:
    Code:
    Private Sub Command21_Click()
    On Error GoTo Err_Command21_Click
    
    
    If Text19.value = "" Then
    MsgBox "Please fill number of copies"
    End If
    
    
    Dim result As Integer
    
    
    If Check_Print = True Then
    result = 1
    End If
        
        If line1_chk.value = -1 Then
        CheckTable ("W177-L")
         If showme = 1 Then
          MsgBox "Result is: " & showme
            'DoCmd.OpenReport "Print_W177-L", acViewPreview
            'If result = 1 Then
            'DoCmd.PrintOut , , , , Text19.Value, False
            'End If
          Else
          MsgBox "Result is: " & showme
         End If
        End If
        
        
    
    
    Exit_Command21_Click:
        Exit Sub
    
    
    Err_Command21_Click:
        MsgBox Err.Description
        Resume Exit_Command21_Click
        
    End Sub

  9. #9
    Minty is online now VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,158
    What is text19 ?
    Is it a combo, a textbox, a date field, and option group?

    It's really helpful if you call controls names that vaguely indicate their purpose. Names like

    txtMyValue
    cboMySelection
    txtReportDate
    optPrintCopies

    Would make all you code a lot easier to understand both for you and outsiders.

    You aren't referencing the option group (Frame41) anywhere as far as I could see?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  10. #10
    luckydead is offline Novice
    Windows 10 Office 365
    Join Date
    Nov 2020
    Posts
    25
    it is textbox that will store value 1 or 2 or other number

    Anyway i remove the radio buttons i think it would be good, but better was make checkboxes and add + if one checkbox is enable disable the others and work like a charm no problems with check boxes.

  11. #11
    Minty is online now VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,158
    I think your code could be much simpler with the use a select case structure to set some variables and then simply print or preview based the variables you set earlier in the code.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  12. #12
    Minty is online now VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,158
    If you go back to your option button group you can simplify your code to this;
    Code:
    Private Sub Command21_Click()    
        Dim sTable          As String
        Dim sPrint          As String
                
        On Error GoTo Err_Command21_Click
        
        If (Val(Me.Text19) + 0) < 1 Then
            MsgBox "Please fill number of copies"
            Exit Sub
        End If
    
    
        Select Case Me.optLines
        
            Case 1
                sTable = "W177-L"
                MsgBox "Result is: " & showme
                Exit Sub
    
            Case 2
                sPrint = "Print_H247-L"
                
            Case 3
                sPrint = "Print_W177-R"
            
            Case 4
                If MsgBox("Click Yes for V177-L or No for W177-L !", vbYesNo + vbQuestion) = vbYes Then
                    sPrint = "Print_W177-R"
                Else
                    sPrint = "Print_W177-L"
                End If
                '
            Case 5
                sPrint = "Print_W247-L"
        
            Case 6
                sPrint = "Print_H243-L"
            
            Case 7
                If MsgBox("Click Yes for H247-R or No for W247-B !", vbYesNo + vbQuestion) = vbYes Then
                    sPrint = "Print_H247-R"
                Else
                    sPrint = "Print_W247-R"
                End If
            Case 8
                If MsgBox("Click Yes for H243-R or No for V177-R !", vbYesNo + vbQuestion) = vbYes Then
                    sPrint = "Print_H243-R"
                Else
                    sPrint = "Print_V177-R"
                End If
                
        End Select
           
        DoCmd.OpenReport sPrint, acViewPreview
    
    
        If CheckPrint Then DoCmd.PrintOut , , , , Me.Text19, False
    
    
    Exit_Command21_Click:
        Exit Sub
    
    
    
    
    Err_Command21_Click:
        MsgBox Err.Description
        Resume Exit_Command21_Click
        
    End Sub
    You could easily add extra options to get rid of the other message boxes.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 04-22-2017, 04:31 PM
  2. Formatting radio buttons
    By Bradex in forum Forms
    Replies: 2
    Last Post: 04-27-2016, 04:57 PM
  3. Radio Buttons
    By maguyver in forum Access
    Replies: 3
    Last Post: 07-07-2012, 10:39 AM
  4. Radio Buttons
    By ccordner in forum Forms
    Replies: 1
    Last Post: 01-27-2012, 09:56 AM
  5. Radio Buttons
    By neil123williams in forum Forms
    Replies: 8
    Last Post: 11-11-2011, 03:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums