Recordset.RecordCount

raisbecp

Registered User.
Local time
Today, 06:54
Joined
Feb 15, 2002
Messages
32
I need to count the records in a subform when I click a command button. I have an if statement that performs a funtion, but I need it to end if there are less than 3 records in the active subform.

Private Sub Command24_Click()

Forms![Audit check]![Audit Filter].SetFocus

If ??????????? > 2 Then

DoCmd.GoToRecord , , acFirst
[status1] = Forms![Audit check]![Audit Filter]![Pass/Fail]

Forms![Audit check]![Audit Filter].SetFocus
DoCmd.GoToRecord , , acNext
[status2] = Forms![Audit check]![Audit Filter]![Pass/Fail]

Forms![Audit check]![Audit Filter].SetFocus
DoCmd.GoToRecord , , acNext
[status3] = Forms![Audit check]![Audit Filter]![Pass/Fail]

If [status1] = "fail" Or [status2] = "fail" Or [status3] = "fail" Then
Status = "Audit"
Else
Status = "Pass"
End If

Else
Status = "Audit"
End If


End Sub
 
Last edited:
Post your code and I will give it a whack!
 
=Count(*) in an unbound textbox in the subform footer will give you the subform record count
 
I can't rally tell what you are trying to do. Can you attatch your database to a post.?
 
You can open a recordset object for your subform using a WHERE clause based on your main form's PK. Use Move First, Move Last to count the records and then have


if rstMySubform.RecordCount >2.....etc.
 
Assuming the command button is on the main form:-

If Me.[nameOfSubform].Form.RecordsetClone.RecordCount > 2 Then
..............
..............
 

Users who are viewing this thread

Back
Top Bottom