Results 1 to 8 of 8
  1. #1
    adnancanada is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2010
    Posts
    121

    how to open pass through query with recordset

    I am running pass through query in Access 2013 VBA code back end is SQL Server. I want to pass parameter to query.




    Private Sub Command4_Click()
    Dim db As DAo.Database


    Dim rs As DAo.Recordset

    Set db = OpenDatabase("", False, False, "ODBC;")
    Set rs = db.OpenRecordset("SELECT PO as PurchDoc, DATE as [Created on], VDRBNBR as Vendor, TM1 as TERM1, TM2 as [TERM2] FROM tblPO where vdrnbr ='Parameter'", dbOpenDynaset, dbSeeChanges)


    If Not rs.EOF Then rs.MoveFirst
    Do Until rs.EOF

    I want to open result in edit mode so that I could I export in excel what is criteria will fit here. Please help.

    move next

    Loop



    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I'm not clear on what you're trying to do, and I don't see a pass through query. If your parameter came from this form:

    Set rs = db.OpenRecordset("SELECT PO as PurchDoc, DATE as [Created on], VDRBNBR as Vendor, TM1 as TERM1, TM2 as [TERM2] FROM tblPO where vdrnbr ='" & Me.Textboxname & "'", dbOpenDynaset, dbSeeChanges)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    adnancanada is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2010
    Posts
    121
    Quote Originally Posted by pbaldy View Post
    I'm not clear on what you're trying to do, and I don't see a pass through query. If your parameter came from this form:

    Set rs = db.OpenRecordset("SELECT PO as PurchDoc, DATE as [Created on], VDRBNBR as Vendor, TM1 as TERM1, TM2 as [TERM2] FROM tblPO where vdrnbr ='" & Me.Textboxname & "'", dbOpenDynaset, dbSeeChanges)
    Thank you very much for answer it.

    My question is that how would I get all the records in edit mode once query is run. I hope you understand it. Yes you are right I have textboxname have Vdrnbr.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Well, one record at a time:

    rs.Edit
    rs!Fieldname = NewValue
    rs.Update
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    adnancanada is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2010
    Posts
    121
    Quote Originally Posted by pbaldy View Post
    Well, one record at a time:

    rs.Edit
    rs!Fieldname = NewValue
    rs.Update


    I dont want to add new value and update. I want to open all the fields in edit mode.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    That is editing the record. Are you wanting the user to be able to edit records? If so, you'll need to use a form based on a query or something. The user can't interact directly with a recordset.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    adnancanada is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2010
    Posts
    121
    Quote Originally Posted by pbaldy View Post
    That is editing the record. Are you wanting the user to be able to edit records? If so, you'll need to use a form based on a query or something. The user can't interact directly with a recordset.
    I want to open query just like we open query in access. What is the syntax of record set to run query in edit mode for all fields ?

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You can just open an Access query based on a linked SQL Server table. It can use a form for criteria. To the best of my knowledge a pass through query is read-only, so can't be used for editing.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Pass DAO.Recordset into public function
    By Ruegen in forum Programming
    Replies: 1
    Last Post: 07-07-2014, 12:31 AM
  2. Pass recordset field into function
    By Ruegen in forum Programming
    Replies: 6
    Last Post: 04-13-2014, 11:04 PM
  3. Replies: 3
    Last Post: 05-08-2013, 01:29 PM
  4. recordset open error on SQL query
    By Siuxia in forum Programming
    Replies: 5
    Last Post: 05-30-2012, 08:02 AM
  5. Replies: 2
    Last Post: 01-14-2012, 05:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums