Results 1 to 2 of 2
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have the following recordset:

    Dim rs As DAO.Recordset
    Set rs = CurrentDb.OpenRecordset("SELECT Productid, code, categoryid,supplierid, size, ddu, grossprice,

    office,cons,vip,dealer,pref ,bosch,drummer,oem,rig FROM products")

    ' fix office prices
    rs.MoveFirst
    Do
    .............
    I need to fix up the prices only in those cases where supplierid = 2.how can i change the recordset?

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    Quote Originally Posted by freelance View Post
    Set rs = CurrentDb.OpenRecordset("SELECT Productid, code, categoryid,supplierid, size, ddu, grossprice,
    office,cons,vip,dealer,pref ,bosch,drummer,oem,rig FROM products where products.supplierid=2")
    Assuming supplierID is a number.

    If you are not sure of the sql, build the query in the query grid, then copy the SQL from there.

    It is also a good idea to use
    Code:
    Dim sql as string
    sql = SELECT Productid, code, categoryid,supplierid, size, ddu, grossprice, office,cons,vip,dealer,pref ,bosch,drummer,oem,rig FROM products where products.supplierid=2"
    Debug.print sql
    Set rs = CurrentDb.OpenRecordset(sql)
    Putting the sql into a variable allows you to capture it with a debug.print statement, If you are getting errors, or the wrong results, you can copy the sql from the immediate window, and paste it into a new query to work out what the problem is.
    Regards
    John



Posting Permissions

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