Count

outandabout24

Registered User.
Local time
Today, 12:49
Joined
Dec 29, 2009
Messages
22
Can anyone help? Here is what I have already, Please see attached.

Here is what I am trying to do.

I enter the players names in the text box then they appear in a large txt box. What I would like to do is to have another txt box that counts the number of players that are in the text box. Would this be a count function? How do I do this? Thanks
 

Attachments

Can anyone help? Here is what I have already, Please see attached.

Here is what I am trying to do.

I enter the players names in the text box then they appear in a large txt box. What I would like to do is to have another txt box that counts the number of players that are in the text box. Would this be a count function? How do I do this? Thanks


Use a listbox or combo box control to display/manipulate (to some degree) your data then use its count method to return the total. Do a search on these controls
 
Had a look at your form and I see your table for team has [players] in it
Rather than trying to store the players in a delimited box, make a players table such as:

tblPlayers
=======
PlayerID
TeamID (FKID)
FirstName
LastName
Tel
etc

Even Better Though Seperate contacts from players

tblPlayers
========
PlayerID
ContactID (FKID)
TeamID (FKID)
StartDate
EndDate

tblContacts
=========
ContactID
FirstName
LastName
Blah Blah Blah
 
PS: If you dont change your table setup heres the answer to your question

Code:
Public Function fPL_CNT() As Integer
    Dim strPlayers As String
        strPlayers = Me.Player.Value
    Dim intCnt As Integer, intPos As Integer, intPosT As Variant
    intPosT = 1: intPos = 1
    Do Until intPosT = 0
    intPosT = InStr(intPos, strPlayers, ";", vbBinaryCompare)
    intPos = intPosT + 1
    Debug.Print intPos
    intCnt = intCnt + 1
    Loop
    fPL_CNT = intCnt - 1
End Function
 
Thanks for the help... One question.. I would need to post the code you provided in the text box where I want the count displayed.. in the event procedure?
 
Thanks for the help... One question.. I would need to post the code you provided in the text box where I want the count displayed.. in the event procedure?

Put the code in a standard module and in your text box use = fPL_CNT
Save the standard module under a different name - ie mPL_CNT
 
Here is what I did and for some reason it is not working.. I made a module named mpl_CNT and then created my txtbox and named it Players and put =fpl_cnt into before update event.
 

Attachments

I don't see the aim of your "database". You don't have any tables?
 
I have a table on another project so I just have a example to post here...
 
Use a listbox control for your players, not a textbox. How far have you gotten already?
 
Sorry - mislead you slightly,,,
Code is now in your form

Using as triggers:
Next and Prev record (you need to err trap these)
Form_Load
 

Attachments

Sorry - mislead you slightly,,,
Code is now in your form

Using as triggers:
Next and Prev record (you need to err trap these)
Form_Load

Still implementing a textbox? A textbox really isn't suited for this sort of thing, but a listbox or other list handling controls are. It's even alot easier adding and deleting players without the need of a module.:)

We would agree the original idea (from the OP) isn't practical and we should aim to direct the OP in the "right" path. Using a subform is the answer to this thread.
 
We would agree the original idea (from the OP) isn't practical and we should aim to direct the OP in the "right" path. Using a subform is the answer to this thread.

If you look at post number 3 I believe that I have made my point .....
 
If you look at post number 3 I believe that I have made my point .....

You sure did. In that case, you would have resorted to using a listbox. It would have been easier for the user to work with (in my opinion):)
 
You sure did. In that case, you would have resorted to using a listbox. It would have been easier for the user to work with (in my opinion):)

Listbox, Treeview, SubForm, Multiple spawned textboxes, or Exactly as the OP has it: Thats more a aesthetic decision

A listbox will prob look the best though:D
 
Absolutely dcb. I hear there are some new grid controls in 2010 (by the way), can't wait hehe!!

Oops... look at us filling up this thread with our little discussions. Apologies lol
 

Users who are viewing this thread

Back
Top Bottom