Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Input box not showing (Access 2002)

    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

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Input box not showing (Access 2002)

    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
    Francois

  3. #3
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Input box not showing (Access 2002)

    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

  4. #4
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Input box not showing (Access 2002)

    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 <img src=/S/doze.gif border=0 alt=doze width=15 height=15> when I answer you this morning.
    Francois

  5. #5
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Input box not showing (Access 2002)

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •