Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2006
    Posts
    108

    Unanswered: Custom Query Question

    I was asked to setup a database by a couple of uhh Computer illiterate people. after the DB was created they kept wanting to add several reports, all with seperate buttons(which means seperate queries for me) after around adding the 8th query/report i decided to use some custom queries and i was wondering if i could do this:

    Have a table [customquerytbl] with [nametxt] and [querymemo] and of course the [id]

    have a dropdown box that pulls from the nametxt field and a button that says "run report"

    by clicking the button it will create a report based off of the SQL query that is stored in the table.

    what would the on-click be for that button, i cant seem to get it right.

    thanks in advance --

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    one (DAO) way is to have all the reports look at a single query 'myQuery' and change it's SQL to suit.

    dim qdef as dao.querydef
    set qdef = currentdb.querydefs("myQuery")
    qdef.SQL = "blah blah blah blah SQL from the memo"
    qdef.close
    set qdef= nothing
    ...and then run the report as usual.

    izy
    currently using SS 2008R2

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    yes it possible
    you could use a form to set whatever parameters you require, and then either push OR pull the parameters from form to report

    you can create the SQL to be used in the report as part of the forms on open event. you may want to look at the reports nodata event to handle any SQL that returns no queries.

    Personally I prefer pulling parameters from a form.

    yu can also set parameters as part of the parameters on the call to open the report (I thinks its soemthing like docmd openreport... sorry cant be too specific, not on a Microsoft platform at present...

    the code is something like frms!<myformname>!<myparameter>

    you probably need to bracket the assignment with an error trapping routine, just incase the parameter form is not open. You can also use that error trapping routine to set up test parameters if required.
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Jul 2006
    Posts
    108
    alright ill try that. thank you.

Posting Permissions

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