• Input box not showing (Access 2002)

    Author
    Topic
    #363994

    I have a form that has an input box to receive the typed up the month of the year with this code.

    Function strMonth() As String
    ‘ Get the Month of the report from the user
    strMonth = InputBox(“Type in the month.”, “Month of Year”)
    End Function

    Private Sub Report_Activate()
    ‘ Figure TotalUOS/Expected

    Dim strTotalUOS As Variant
    On Error GoTo ErrorHandler
    strTotalUOS = strMonth
    txtMonth = strTotalUOS
    etc

    That works as advertised.

    The user approaches this form from two directions. The monthly report is printed via a switchboard and the input works as advertised. Then at the end of the year there is a button that comes up on the frmClient This button click does several things msgbox that asks if all data entered, then prints report with a label that is only visible when this button is used, then it updates three fields in a separate table. When this button is used the input box does is not displayed. I have but the function both on the report and in the module without success.

    Thank you. Fay

    Viewing 0 reply threads
    Author
    Replies
    • #557424

      Fay,

      If I understand what you write, then you have a function in a module and you want to use it from within a report or a form.

      Then you have to make your function public

      Public Function strMonth() As String
      ‘ Get the Month of the report from the user
      strMonth = InputBox(“Type in the month.”, “Month of Year”)
      End Function

      • #557439

        Good morning Francois

        Okay I placed this in Modular 1
        Public Function strMonth() As String
        ‘ Get the Month of the report from the user
        strMonth = InputBox(“Type in the month.”, “Month of Year”)
        End Function

        Then this on a report
        Private Sub Report_Open(Cancel As Integer)
        Dim strMonth As String
        txtMonth = strMonth ‘ This is a textbox
        End Sub

        It is now saying I can assign a value to this object. I have remove the Dim strMonth As String from the second block and it gives me the same message. PS Shifting gear on this same form I have tried using just a textbox with =[Type out the Month] and get a #Name as results.

        Thank you Fay

        • #557463

          Of course. When you make a function public, you can’t use the name of the function for a variable:

          Rename the function to:
          Public Function GetMonth() As String
          ‘ Get the Month of the report from the user
          GetMonth = InputBox(“Type in the month.”, “Month of Year”)
          End Function

          and in the report:

          txtMonth = GetMonth()

          I think I was doze when I answer you this morning.

        • #557464

          Okay I got the report to work, ie displaying input box and input on report. (By the way I can never express my appreciation for your help yesterday, but thanks.) To correct the problem I was having with the tsxtbox receiving the data I had to put the code in On Activation event.

          I now have it so the message box comes up when the cmdApril button is clicked on the frmClient. But the data isn’t put into the textbox. I put the code like this

          This is within the click command of the cmdApril button
          Dim strYrMonth As String
          strYrMonth = strMonth

          DoCmd.OpenReport “rptJonCombined”
          txtMonth = strYrMonth

          What I can’t understand is why the code on the report is not activating itself just because we are going through a different route?

          Thanks Fay

    Viewing 0 reply threads
    Reply To: Input box not showing (Access 2002)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: