Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2003
    Posts
    8

    Unhappy Unanswered: QueryDef does not work!

    Hi everyone

    I am a newbie in Access Modules and & I am facing a problem

    I have a database, which has 2 tables (Product , Order) ..
    I have a query named qryProductOrder
    I have a form, called frmProductOrder, which has all fields in qryProductOrder, it has some fields like (orderID, productID, date, etc)


    I have a button , when I click on it, it should jump to the record set which shows OrderID = 3

    On the click event of the button, I wrote the following code

    dim qdf as QueryDef
    set qdf = CurrenDb.QueryDefs("qryProductOrder")
    qdf.sql = "select * from qryProductOrder where orderID = 3"
    qdf.close



    but when i run it I get an error message & then the program closes!

    Hope someone could help me

    Thanks in advance for anyhelp

  2. #2
    Join Date
    Sep 2003
    Location
    Texas
    Posts
    13
    How about setting the record source of the form = "your SQL statement" on the click event of the button?

  3. #3
    Join Date
    Sep 2003
    Posts
    8
    Thanks very much for the help!

    but, how can I set the record source of the form to sql statement ? I a newbie and I don't understand a lot of basic procedures.

    Thanks so much

  4. #4
    Join Date
    Sep 2003
    Location
    Texas
    Posts
    13
    form.recordsource="select * from qryProductOrder where orderID = 3"

    I think that will work.

  5. #5
    Join Date
    Sep 2003
    Location
    Texas
    Posts
    13
    Don't forget the ";" at the end of your sql statement....

  6. #6
    Join Date
    Sep 2003
    Posts
    8
    Fantastic!
    Yah it works now .... thanks a lot

    BTW: I noticed that it doesn't recognize the ";" unlike some programming languages.

    But that was really helpful

Posting Permissions

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