Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2013
    Posts
    2

    Unanswered: module will not work properly

    hello, i have a situation. i am creating a school database system, ive suddenly stocked in the module function. i created form that register student every year. in my query, i want the user to calculate all registered student in each year. i succeeded in doing that using my parameter in my query date field and a function in my vba module

    Module
    Function ParmValue() As Date
    ParmValue = InputBox("date here")
    End Function

    Query
    creiterial=parmvalue()

    now i want that the chosen date should be displayed on my report label call "lblyear". the thing is i just cant call any control in my function. why?, can anyone help me please?

  2. #2
    Join Date
    Jan 2009
    Location
    Kerala, India
    Posts
    183
    Use a Textbox, instead of a label, and write the expression:

    =Paramvalue()
    in the Control Source Property of the Textbox.

    If you are using Access2007 or later version of Access then you may assign a Date into a Temporary Variable and use that value.

    Code:
    Function ParmValue() As Date
    Tempvars.Add "ParmValue", InputBox("date here")
    End Function
    You can also do it in a Macro with the SetTempvar Action.

    1. Use the Value in Query criteria expression Tempvars![ParamValue]
    2. Use it in a Textbox on the Report, in place of Label, with the expression =Tempvars![ParamValue]
    Last edited by apr pillai; 08-28-13 at 15:34.
    www.MsAccessTips.com (Learn MS-Access Tips & Tricks)
    Learn Advanced MS-Access Programming with sample VBA Code.

    All responses are based on Access 2003/2007

Posting Permissions

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