By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 909 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

How to count number of rows in a subform?

P: 15
I have created a form where one text box and two command buttons named Search and Clear are present. Under all these fields I am also including a subform which displays all the values stored in Patient table.

When I enter any word in the name text box and click enter then the values in sub form only display the details of the patient whose first name or last name matches with the given name. When button Clear is hit ( in future I am planning to make it cancel button , so that to cancel the operation ) textbox becomes empty.

I want to count the number of rows that result from the above operation.
I mean all the rows which are displayed in the subform.

If the particular patient exists in that Subform I want to implement a functionality where, when I click on the particular patient's row in sub from it should open Form which contains the details of that particular patient.

It would be great if someone can help me regarding this .....

Thanks,
Pdesh3
May 11 '07 #1
Share this Question
Share on Google+
1 Reply


JConsulting
Expert 100+
P: 603
I have created a form where one text box and two command buttons named Search and Clear are present. Under all these fields I am also including a subform which displays all the values stored in Patient table.

When I enter any word in the name text box and click enter then the values in sub form only display the details of the patient whose first name or last name matches with the given name. When button Clear is hit ( in future I am planning to make it cancel button , so that to cancel the operation ) textbox becomes empty.

I want to count the number of rows that result from the above operation.
I mean all the rows which are displayed in the subform.

If the particular patient exists in that Subform I want to implement a functionality where, when I click on the particular patient's row in sub from it should open Form which contains the details of that particular patient.

It would be great if someone can help me regarding this .....

Thanks,
Pdesh3
first part

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2. Dim rs As Object
  3. Set rs = Me.subfrm1.Form.RecordsetClone  'where subfrm1 is your subform
  4. Me.MyCount = rs.RecordCount   ' where MyCount is your textbox
  5. End Sub
  6.  
second part

Expand|Select|Wrap|Line Numbers
  1.     Dim stDocName As String
  2.     Dim stLinkCriteria As String
  3.     stDocName = "MyFormName"
  4.     stLinkCriteria = "ID=" & Me.myID
  5.     stDocName = "FormOneClone"
  6.     DoCmd.OpenForm stDocName, , , stLinkCriteria
  7.  
J
May 12 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.