Results 1 to 3 of 3

Thread: Weird problem with SQL RecordSet (DAO) [RESOLVED]

Threaded View

  1. #1

    Thread Starter
    Member Birth's Avatar
    Join Date
    Jan 2003
    Location
    Montreal
    Posts
    57

    Exclamation Weird problem with SQL RecordSet (DAO) [RESOLVED]

    Hi,

    When I use this code
    VB Code:
    1. ...
    2. Public RS As Recordset
    3. -----------------------------
    4. Dim SQL As String
    5.  
    6. SQL = "SELECT Table.NAM, Table.* From Table WHERE Table.NAM='" & NM$ & "'"
    7. or
    8. SQL = "SELECT DISTINCTROW CDP.NAM, CDP.* From CDP WHERE CDP.NAM='" & NM$ & "'"
    9.  
    10. Set RS = DB.OpenRecordset(SQL, dbOpenDynaset)
    11.  
    12. While Not RS.EOF
    13.     If RS("NAM") = NM$ Then
    14.         RS.Edit
    15.         RS("Number") = 1
    16.         RS("Status") = "Help"
    17.         ....
    18.         RS.Update
    19.     End If
    20.     RS.MoveNext
    21. Wend
    I get "Item not found in this collection" only for RS("NAM"). All of the other fields are there.

    I've been trying to figure this one out all day! What the hell is wrong with that?

    If I do...
    VB Code:
    1. Dim fld As Field, td As TableDef
    2.            
    3.             Set td = DB.TableDefs!cdp
    4.  
    5.             For Each fld In td.Fields: Debug.Print fld.Name: Next
    It displays all of the fields including 'NAM'.

    Please help!
    Last edited by Birth; Dec 11th, 2003 at 10:02 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width