Results 1 to 4 of 4
  1. #1
    klnlsu is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Apr 2015
    Posts
    107

    ADODB recordset not giving results I want

    Can someone take a look at my code below and tell me if there is a syntax error in my rs1.Open statement? The Dcount statement is giving me the correct result (2 records), but my rs1.EOF is TRUE immediately following the open statement.



    StrWhere = "([CustNumber] Like '*ROB102*')"

    StrMsg = MsgBox("You are about to add " & DCount("*", "tblSalesSpecialPricing", StrWhere) & " record(s).", vbOKCancel + vbDefaultButton2)
    If StrMsg = vbCancel Then Exit Sub

    Dim Con1 As New ADODB.Connection, Con2 As New ADODB.Connection

    Set Con1 = CurrentProject.Connection
    Set Con2 = CurrentProject.Connection

    Dim rs1 As New ADODB.Recordset, rs2 As New ADODB.Recordset

    rs1.Open "SELECT * FROM tblSalesSpecialPricing WHERE " & StrWhere, Con1, adOpenDynamic, adLockPessimistic

    While Not rs1.EOF

  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,518
    For ADO, you need % rather than * as the wildcard.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    klnlsu is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Apr 2015
    Posts
    107
    That's right! Thanks for reminding me!

  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,518
    Happy to help!
    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. Change ADODB.Recordset by New
    By Remphan in forum Programming
    Replies: 1
    Last Post: 03-15-2016, 07:31 AM
  2. Difficulty returning ADODB recordset from function
    By randman1 in forum Programming
    Replies: 4
    Last Post: 07-19-2012, 01:07 PM
  3. form/subform ADODB recordset
    By rashima in forum Forms
    Replies: 1
    Last Post: 04-27-2012, 12:19 PM
  4. Replies: 2
    Last Post: 03-08-2012, 12:59 PM
  5. ADODB Recordset behaving strangely
    By RayMilhon in forum Programming
    Replies: 4
    Last Post: 11-04-2011, 12:21 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