Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2003
    Posts
    1

    Unanswered: New To Access - Passing Variables from Forms/Date Queries?

    Hi Guys,

    I am new to Access and trying to develop a simple application:

    1) A form that will take a "Name" and a "Date" from User.
    2) When user clicks "OK", it will open a report. (I am using MACRO here)
    3) When the report is opened by MACRO, the name will be passed to a report and will be displayed on the report....How to achieve this?
    4) There will be a query on the report that will be executed with criteria "Date" field entered by the user. I have a table named as "PEOPLE" which have columns "Name" / "Occupation" / "Birthdate" . I want to write a query that will compare the Form.Date (entered by user) with People.Birthdate and will display the matching records. "Date" and "Birthdate" format is DD/MM/YY but I need only records that match DD/MM in this query.

    For Example;
    If user enters NAME=John and DATE=22/06/1980 in the form, I will open a report, PRINT THIS NAME on this report (HOW TO DO THIS, this is my first question) and then display the records that have Birthday Field 22/06/** (HOW TO DO THIS, this is my second question)


    I am open to any ideas, I have passed couple of hours by looking Access but because of inadequate experience and poor documentation, I am stucked at this point. Your help and ideas will be appreciated.

    Thank you!

  2. #2
    Join Date
    Jul 2003
    Posts
    38
    You won't find much about that in the documentation, because it can't be done with Access standard functions. You'll have to write VBA-code.
    Anyway, this is easy code, like:

    reports(REPORTNAME)(Feldname) = forms(FORMNAME)(Textbox)
    reports(REPORTNAME).recordsource = "Select * from blabla where name = " & forms(FORMNAME)(Datumsbox)

  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    the date question is not so easy 'cos you want any year.
    something along the lines of
    SELECT * FROM theTable WHERE (day([Birthdate]) & "/" & month([Birthdate])) Like forms!formName![Date] & "*"

    but your user must only enter dd/mm (or you use code to strip off any /yyyy)




    i see you EMPHASISE macros ...best of luck!




    izy

Posting Permissions

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