Submit button will only work for half the options in a combo box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sschmidt460
    New Member
    • Aug 2015
    • 15

    #1

    Submit button will only work for half the options in a combo box

    Code:
    Private Sub Submit_Button_Click()
    If IsNull(Me.Type_Text) Or Me.Type_Text = "" Then
        MsgBox "Please select criteria for Report Type.", vbExclamation, "Attention"
    Else
        If Me.Type_Text = "Requisitions" Then
            DoCmd.OpenForm "Date Form"
        Else
            If [Forms]![Report Form]![Equipment Combo] = "" Then
                DoCmd.OpenReport "Equipment Inventory Report", acViewPreview
            End If
        End If
    End If
    End Sub
  • sschmidt460
    New Member
    • Aug 2015
    • 15

    #2
    so in the combo box I have the options "requisitio ns" and "inventory" . the submit button works for the requisitions option and opens the date form, but it does not perform the action and go to the "equipment inventory report" when i click on "inventory

    Comment

    • jforbes
      Recognized Expert Top Contributor
      • Aug 2014
      • 1107

      #3
      Is [Equipment Combo] blank?

      You might want to put something like the following to see if it is falling through your code without doing anything:
      Code:
      Private Sub Submit_Button_Click()
       If IsNull(Me.Type_Text) Or Me.Type_Text = "" Then
           MsgBox "Please select criteria for Report Type.", vbExclamation, "Attention"
       Else
           If Me.Type_Text = "Requisitions" Then
               DoCmd.OpenForm "Date Form"
           Else
               If [Forms]![Report Form]![Equipment Combo] = "" Then
                   DoCmd.OpenReport "Equipment Inventory Report", acViewPreview
               [iCODE]Else[/iCODE]
                   [iCODE]MsgBox "Please fill provide the Equipment Something.", vbExclamation, "Attention"[/iCODE]
               End If
           End If
       End If
       End Sub

      Comment

      • sschmidt460
        New Member
        • Aug 2015
        • 15

        #4
        I added that code and when I clicked the "submit button, that msgBox did pop up. How do I fix it so that it will link the equipment in the box. I am selecting a piece of equipment in the previous form and its working for the "requisitio ns" option of the combo box, but not the 'inventory"

        Comment

        • jforbes
          Recognized Expert Top Contributor
          • Aug 2014
          • 1107

          #5
          I'm not really sure what you are attempting to do, so this is my best guess. My guess is that the test for an [Equipment Combo] selection is backwards, so I would swap the sign (or swap the code).

          Swapping Sign:
          Code:
          Private Sub Submit_Button_Click()
            If IsNull(Me.Type_Text) Or Me.Type_Text = "" Then
                MsgBox "Please select criteria for Report Type.", vbExclamation, "Attention"
            Else
                If Me.Type_Text = "Requisitions" Then
                    DoCmd.OpenForm "Date Form"
                Else
                    If Nz([Forms]![Report Form]![Equipment Combo], "") <> "" Then
                        DoCmd.OpenReport "Equipment Inventory Report", acViewPreview
                    Else
                        MsgBox "Please fill provide the Equipment Something.", vbExclamation, "Attention"
                    End If
                End If
            End If
            End Sub
          Or, Swapping Code:
          Code:
          Private Sub Submit_Button_Click()
            If IsNull(Me.Type_Text) Or Me.Type_Text = "" Then
                MsgBox "Please select criteria for Report Type.", vbExclamation, "Attention"
            Else
                If Me.Type_Text = "Requisitions" Then
                    DoCmd.OpenForm "Date Form"
                Else
                    If [Forms]![Report Form]![Equipment Combo] = "" Then
                        MsgBox "Please fill provide the Equipment Something.", vbExclamation, "Attention"
                    Else
                        DoCmd.OpenReport "Equipment Inventory Report", acViewPreview
                    End If
                End If
            End If
            End Sub

          Comment

          Working...