filters and number of records

R

R

I have forms that I have created which have filters on them to only display
certain records. What I am trying to do get the number of records that get
passed through these filters. I have applied the filters in the properties
of Access and I am trying ot get the number of records within the code that I
am writing to use somewhere else.

I am using Access 2000.

Thanks
 
O

Ofer

You can use this code

Dim MySet As Recordset
Set MySet = Forms![FormaName]![SubFormShort].Form.RecordsetClone 'For sub Form
Set MySet = Forms![FormaName].RecordsetClone ' For Form

If MySet.RecordCount <> 0 Then
MySet.MoveLast
End If
msgbox MySet.RecordCount
 
R

R

hey i tried this code but when i run it i keep getting "type mismatch" error
any suggestions
thanks


Ofer said:
You can use this code

Dim MySet As Recordset
Set MySet = Forms![FormaName]![SubFormShort].Form.RecordsetClone 'For sub Form
Set MySet = Forms![FormaName].RecordsetClone ' For Form

If MySet.RecordCount <> 0 Then
MySet.MoveLast
End If
msgbox MySet.RecordCount

R said:
I have forms that I have created which have filters on them to only display
certain records. What I am trying to do get the number of records that get
passed through these filters. I have applied the filters in the properties
of Access and I am trying ot get the number of records within the code that I
am writing to use somewhere else.

I am using Access 2000.

Thanks
 
R

R

sorry the error that i keep getting is on the line
"Set MySet = Forms![FormaName].RecordsetClone"
i put set MySet = Me.RecordsetClone
it says its a type mismatch error
thanks
 
O

Ofer

I just tried it and I get the result, can you please post the code, subform
name, form name

R said:
hey i tried this code but when i run it i keep getting "type mismatch" error
any suggestions
thanks


Ofer said:
You can use this code

Dim MySet As Recordset
Set MySet = Forms![FormaName]![SubFormShort].Form.RecordsetClone 'For sub Form
Set MySet = Forms![FormaName].RecordsetClone ' For Form

If MySet.RecordCount <> 0 Then
MySet.MoveLast
End If
msgbox MySet.RecordCount

R said:
I have forms that I have created which have filters on them to only display
certain records. What I am trying to do get the number of records that get
passed through these filters. I have applied the filters in the properties
of Access and I am trying ot get the number of records within the code that I
am writing to use somewhere else.

I am using Access 2000.

Thanks
 
R

R

Sorry...this is the code that I have...it should be so simple...I'm sure I'm
just missing something simple.

Dim theRecSet As RecordSet

Set theRecSet = Fprms![Subjects_RankUnder7].RecordsetClone *****this is the
line that has the type mismatch error

If theRecSet.RecordCount <> Then
theRecSet.MoveLast
End IF

MsgBox theRecSet.RecordCount

The form I am usins is named Subjects_RankUnder7, which had a filter applied
on it through the properties.

I don't know if you can help. Thanks for all of your suggestions so far.



Ofer said:
Did you declare the Dim MySet As Recordset


R said:
sorry the error that i keep getting is on the line
"Set MySet = Forms![FormaName].RecordsetClone"
i put set MySet = Me.RecordsetClone
it says its a type mismatch error
thanks
 
O

Ofer

From what I see you wrote

Set theRecSet = Fprms![Subjects_RankUnder7].RecordsetClone *****this is the
It should be
Set theRecSet = Forms![Subjects_RankUnder7].RecordsetClone

the Fprms should be Forms
R said:
Sorry...this is the code that I have...it should be so simple...I'm sure I'm
just missing something simple.

Dim theRecSet As RecordSet

Set theRecSet = Fprms![Subjects_RankUnder7].RecordsetClone *****this is the
line that has the type mismatch error

If theRecSet.RecordCount <> Then
theRecSet.MoveLast
End IF

MsgBox theRecSet.RecordCount

The form I am usins is named Subjects_RankUnder7, which had a filter applied
on it through the properties.

I don't know if you can help. Thanks for all of your suggestions so far.



Ofer said:
Did you declare the Dim MySet As Recordset


R said:
sorry the error that i keep getting is on the line
"Set MySet = Forms![FormaName].RecordsetClone"
i put set MySet = Me.RecordsetClone
it says its a type mismatch error
thanks
 
K

Kevin K. Sullivan

It sounds like you have a reference to ADO and not DAO. In the code
editor, go to Tools->References and check Microsoft DAO 3.6. If you
aren't using ADO/ don't know what ADO is, remove the reference to
Microsoft ActiveX Data Objects #.# . If you want to keep both
libraries, make sure that you are explicit in the declaration of objects
that are in both libraries:

Dim MySet as DAO.Recordset ' A form's RecordsetClone property returns a
DAO.Recordset object

HTH,
 
Top