Sub OpenADO()
Dim rec As New ADODB.Recordset
rec.Open "tblCountries", CurrentProject.Connection, adOpenStatic, adLockOptimistic
With rec
While Not .EOF
Debug.Print !txtCountry
.MoveNext
Wend
End With
rec.Close: Set rec = Nothing
End Sub
Replace "tblCountries" with the name of the table, you want to open. Replace "txtCountry", with the name of the field, you want to view.
This will open a recordset, & loop through each record & print the desired field, in the debug window.
You could also try using the recordset function findfirst which will search through the record set to find any records where there is a specific value.
Dim rs As Recordset
Dim Find As String
Dim ID_Number As Integer
Find = "[Identification] = " & ID_Number
rs.FindFirst Find
where ID_Number is a variable used to store the value you are searching for.
I'm trying to change the !LINEABBR field to "18", but this
is not working. Can anyone figure out what's wrong with
this function? Sample records are below:
Dim dbs As DAO.Database
Dim rstSrc As DAO.Recordset
Set dbs = CurrentDb
Set rstSrc = dbs.OpenRecordset("WithoutPairedRoutes", dbOpenDynaset)
With rstSrc
While Not .EOF
If ((!BLOCKNAME = "004-02" And _
!NODEABBRA = "SPRI" And !NODEABBRB = "MLK")) Then
'Edit Record
.Edit
!LINEABBR = "18"
.Update
End If
.MoveNext
Wend
End With
rstSrc.Close
Set rstSrc = Nothing
End Function
Dim dbs As DAO.Database
Dim rstSrc As DAO.Recordset
Set dbs = CurrentDb
Set rstSrc = dbs.OpenRecordset("WithoutPairedRoutes", dbOpenDynaset)
With rstSrc
If .RecordCount>0 then
.MoveFirst
Do While Not .EOF
If ((!BLOCKNAME = "004-02" And _
!NODEABBRA = "SPRI" And !NODEABBRB = "MLK")) Then
'Edit Record
.Edit
!LINEABBR = "18"
.Update
End If
.MoveNext
Loop
End If
End With
rstSrc.Close
Set rstSrc = Nothing
End Function
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.