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

Problems with a calculated control on a subform

Status
Not open for further replies.

clickster

MIS
Feb 19, 2002
89
US
I have a form/subform problem. The form displays general employee information and the subform displays all tickets (this is a very simplistic help desk DB) tied to that person. If it makes any difference, I have the subform displayed in Single Form rather than Datasheet. I have a text box in the subform and would like to display to total number of tickets attributed to that person in this textbox. The field that holds the tickets numbers is [ticketnumber] and there is a field called [id] that is a foreign key. I simply want to get a count of all of the [ticketnumber] tied to that [id]. Thank you.
 
In the subForm's OnCurrent event place code to open a recordset such as

(Define recordset & connection - depending on if its DAO or ADO you're using)

rst.Open "SELECT Count(TicketNumber) As CountOfTickets FROM subForm'sTableName WHERE Id = " & SubForm.IdControlName
subFormTextBoxName = rst!CountOfTickets
rst.Close


'ope-that-'elps

G LS


 
If you want the count to appear on the form, place your calculated control in the subform's form footer. It will not be visible there:
Code:
=Count([ticketnumber])

Place an unbound text box in your form, and set the control source to the above text box:
Code:
=[frmYoursubform subform].[Form]![txtCountField]

Hope this helps.....



 
Sorry I didn't respond sooner, but I've been trying both suggestions and I'm not getting anywhere at all.

Thanks for your suggestions - I'll keep fumbling through it and see if I can get it.

CarolOB
 
The SubForm has a propery
Assume SubForm has name SubForm1
in main form u can have as

SubForm1.RecordSetClone.RecordCount

This will give no of records displayed in subform

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top