Weird problem with SQL RecordSet (DAO) [RESOLVED]
Hi,
When I use this code
VB Code:
...
Public RS As Recordset
-----------------------------
Dim SQL As String
SQL = "SELECT Table.NAM, Table.* From Table WHERE Table.NAM='" & NM$ & "'"
or
SQL = "SELECT DISTINCTROW CDP.NAM, CDP.* From CDP WHERE CDP.NAM='" & NM$ & "'"
Set RS = DB.OpenRecordset(SQL, dbOpenDynaset)
While Not RS.EOF
If RS("NAM") = NM$ Then
RS.Edit
RS("Number") = 1
RS("Status") = "Help"
....
RS.Update
End If
RS.MoveNext
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:
Dim fld As Field, td As TableDef
Set td = DB.TableDefs!cdp
For Each fld In td.Fields: Debug.Print fld.Name: Next
It displays all of the fields including 'NAM'.
Please help! :sick: