Message 1 of 2
Recordset loop ..Help plz!!

Not applicable
02-07-2008
05:46 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
i want to make a loop to check all records in an Access Database to find the id of this record so i wrote the following syntax but error take place so any one can help me in this??
Function PLID(DBPathX As String, STRPLName As String)
Dim PLNAME As String
Dim oAccess As New ADODB.Connection
Dim oRecordset As New ADODB.Recordset
oAccess.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & DBPathX & ";"
oRecordset.Open "Select * From Floor", oAccess, adOpenKeyset, adLockOptimistic
'Start searching in the Access DB in table Floor
Do Until oRecordset.EOF
'If oRecordset![FLAT NAME] = STRPLName Then
'PLID = oRecordset!ID
'Else
'oRecordset.MoveNext
'End If
'Loop
If PLID = "" Then
With oRecordset
.AddNew
![FLAT NAME] = STRPLName
.Update
End With
PLID = oRecordset!ID
End If
End Function
Function PLID(DBPathX As String, STRPLName As String)
Dim PLNAME As String
Dim oAccess As New ADODB.Connection
Dim oRecordset As New ADODB.Recordset
oAccess.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & DBPathX & ";"
oRecordset.Open "Select * From Floor", oAccess, adOpenKeyset, adLockOptimistic
'Start searching in the Access DB in table Floor
Do Until oRecordset.EOF
'If oRecordset![FLAT NAME] = STRPLName Then
'PLID = oRecordset!ID
'Else
'oRecordset.MoveNext
'End If
'Loop
If PLID = "" Then
With oRecordset
.AddNew
![FLAT NAME] = STRPLName
.Update
End With
PLID = oRecordset!ID
End If
End Function