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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Recordset Problem

Status
Not open for further replies.

jessedh

MIS
Apr 16, 2002
96
US
hi I am trying this very basic code and it keeps generating an error saying datatype mismatch... I know I am just missing something very basic... I am using Access 2000

Private Sub Command0_Click()
Dim db As Database
Dim tbl1 As Recordset
Dim count As Integer
Set db = CurrentDb
Set tbl1 = db.OpenRecordset("tbl2Status")

tbl1.MoveFirst
count = 0

While Not tbl1.EOF
count = count + 1
Wend

MsgBox ("There are " & Str$(count) & "Records in the table")
End Sub
 
What are you trying to count? If you are trying to simply get the recordcount, there is simple way to do it. Try this, your count feature isn't counting anything currently..you need to link it to the recordset. Try something like this..it provides the recordcount.


Private Sub Command56_Click()
Dim tbl1 As Recordset
Dim count As Integer

Set rst = CurrentDb.OpenRecordset("Select * from tbl2Status")

Do Until rst.EOF = True
count = count + 1
rst.MoveNext
Loop

intTer = rst.RecordCount

MsgBox (intTer & " records found in this recordset")


End Sub
 
What are you trying to count? If you are trying to simply get the recordcount, there is simple way to do it. Try this, your count feature isn't counting anything currently..you need to link it to the recordset. Try something like this..it provides the recordcount.


Private Sub Command56_Click()
Dim tbl1 As Recordset
Dim count As Integer

Set rst = CurrentDb.OpenRecordset("Select * from tbl2Status")

Do Until rst.EOF = True
count = count + 1
rst.MoveNext
Loop

count = rst.RecordCount

MsgBox (count & " records found in this recordset")


End Sub
 
What are you trying to count? If you are trying to simply get the recordcount, there is simple way to do it. Try this, your count feature isn't counting anything currently..you need to link it to the recordset. Try something like this..it provides the recordcount.


Private Sub Command56_Click()
Dim tbl1 As Recordset
Dim count As Integer

Set tbl1 = CurrentDb.OpenRecordset("Select * from tbl2Status")

Do Until tbl1.EOF = True
count = count + 1
tbl1.MoveNext
Loop

count = tbl1.RecordCount

MsgBox (count & " records found in this recordset")


End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top