Results 1 to 9 of 9

Thread: Access97....need help!!

  1. #1
    Guest

    Exclamation

    Hallo

    I have to alter an existing Access App. One of my questions (at the moment) is How do I send parameters to a report from my own dialog form? I know how to invoke it through access ( the parameters tha is), but I need to display info in a Combo box for the user to select the parameters...and not only typing it in.

    Please help on this one!!

    Thanx

  2. #2
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    What is the code you are using at the moment? Post it up and I'll see what we can do...

    P.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  3. #3
    Guest
    Hi

    Here is the code that opens the report.

    ' Open a report.
    Case conCmdOpenReport
    DoCmd.OpenReport rst![Argument], acPreview

    It is part of a Select Case statement. They invoked the parameter from the table itself with [Type EmployeeNumber]. There are no further code except the SQL Statement.

    Hope this is what you were looking for. Please let me know if you need anything else from the App.

    Thanx

  4. #4
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    When you say 'parameters' what precisely do you mean?
    Are you using a parameterised query to filter the report or what?

    If the query is a parameter query I would use a modal form to return user information and then build a SQL statement.

    Let me have a few more details - i.e. what SQL are you using etc.

    Cheers,

    P.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  5. #5
    Guest
    Sorry for the vagueness but here it is:

    I would like to capture parameters (filter) on a dialog box. I pass this parameters to a SQL statement where I generate the query result for a specific report.

    I know how to do this in VB but this is new to me in Access. I do not know how to construct a query here where I pass one or more than one parameters to a query.

    Please let me know whether this is still unclear.
    Thanx

  6. #6
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    It is easiest to do it in code in Access as well. The code should be pretty well identical in both environments. Simply construct the SQL statement, including your variables and either set the Reports source to that SQL statement or use it as a filter in the OpenReport method.

    If you want to use a pre-defined query (which is less flexible), then you would access its Parameters collection.

    I hope that's clear enough?

    P.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  7. #7
    Guest
    Hallo

    How do I allocate this query in code to a Report at runtime? In VB I use Data Environment and use the "?" to show a parameter must be received for my query. On OpenReport I only see examples where 1 parameter is passed...

    Am I understanding it incorrectly?? Or should I define a query and using the filter of OpenReport to specify the where clause?? How do you handle 2 or more parameters then ask asked above??

    I know....I'm clueless!

  8. #8
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    At the end of the day, you are trying to pass a filtered set of data to a report. You can either send a complete set of data to the report and filter it with the WHERE clause of OpenReport or you can set up the source query to return the filtered set.

    If you want to set up the query as parameterised (which will produce an input box at run time) you can fill these in using the parameters collection (check the help). However, since you are collecting the parameters up front form your VB app, it is easier to create a fully qualified SQL query.

    i.e.

    Code:
    Report "rpt" based on MyTable
    DoCmd OpenReport "rpt",,,"Name = 'Me'"
    or

    Code:
    Report "rpt" based on MyQuery
    Parameterised Query (MyQuery) 
    SELECT * FROM MyTable WHERE ... 
    Name = [Get Name]
    i.e. Query prompts for Name
    DoCmd OpenReport "rpt" - picks up paremeterised query by default...
    or (best)

    Code:
    MySQL = "SELECT * FROM MyTable WHERE Name = " & Me.txtName
    ' picks up name from text box on the form...
    Set rpt.Recordsource = MySQL
    DoCmd OpenReport "rpt"
    Clearer?

    P.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  9. #9
    Guest
    Thanx for your help, I appreciate it.

Posting Permissions

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



Click Here to Expand Forum to Full Width