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!

Need help on Form Function

Status
Not open for further replies.

vig

MIS
Jan 29, 2000
14
US
I need to keep a running count on a form of the number of times a L code appears in the 31 fields of the form, the number of times a C code appears in the 31 fields and etc.(There are other codes.) A field can be empty. Only one code will appear in any cell. I have added a calculation box for each code...Now I need what to put in that box. Thanks for helping a newbie.
 
Are these "C"'s and "L"'s on a main form or a sub form?
 
This is a form opened by a command button in the main form. It is not a subform. thanks.
 
Just a thought (maybe someone has time to code this):<br>
<br>
In VBA combine these 31 fields to one text string (empty fields as blank space). Then you have 31 characters long string which needs to be investigated. With Mid-function and 31-stepped For...Next loop you can go through the string characters one by one and with StrComp function increase the variable value for every occurance of C or L.<br>
<br>
Not an elegant or newbie solution but crossed my mind...<br>
<br>
Al<br>
<br>

 
Vig,<br>
<br>
Your description of the field sounds like a repeating field; i.e., an &quot;array&quot;, if you will. If so, this is NORMALLY a &quot;No, no&quot; in a relational database. Maybe you could describe your file structure a little more.
 
Use a &quot;for each...next&quot; to loop through all controls on a form and use a &quot;select case&quot; to increment your counts. You can put a button on the form and add something like this in the OnClick event:<br>
<br>
Dim ctl as Control<br>
For each ctl in Controls<br>
Select Case ctl<br>
Case (criteria that determines L code)<br>
txtCountL = txtCountL+1<br>
Case (crit for C code)<br>
txtCountC = txtCountC +1<br>
(etc)<br>
End Case<br>
Next ctl<br>
<br>
<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top