Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

recordset code and errors

Status
Not open for further replies.

bluesage

Programmer
Apr 27, 2004
26
CH
hi,

here is some code i got from a site. ive made some changes and tried it but doesnt work. need help

====================================

Private Sub cmdGetRows_Click()

Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strqry As String
Dim strFieldValue As String
Dim varRecords As Variant
Dim intRecord As Integer
Dim intField As Integer

strqry = "uno" (this is a query)
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(strqry, dbOpenSnapshot)
varRecords = rst.GetRows(1)
(here don't know what to do?)
restxt.Value = varRecords(1)

End Sub

====================================

Private Sub cmdGetRows_Click()

Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strTable As String
Dim strFieldValue As String
Dim varRecords As Variant
Dim intRecord As Integer
Dim intField As Integer

strTable = "items"
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(strTable, dbOpenSnapshot)
varRecords = rst.GetRows(10)
Debug.Print "Fourth field in fifth record: " & varRecords(5, 6)

End Sub


=============================

i get this message:

error is:
run-time error '9':
Subscript out of range

=======================
what does this do: varRecords(5, 6)?

thanks
 
Have you tried this ?
[highlight]Set [/highlight]varRecords = rst.GetRows(10)
If UBound(varRecords, 2) >= 4 Then _
Debug.Print "Fourth field in fifth record: " & varRecords(3, 4)

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top