count code

  • Thread starter jesseu via AccessMonster.com
  • Start date
J

jesseu via AccessMonster.com

new to code
need to write a code that counts a fieldbox meets criteria and gives mgsbox.
This is what I have

if ([Text2]) = 6 Then
msgbox "hello"
end if
end sub
thank You
 
J

John W. Vinson

new to code
need to write a code that counts a fieldbox meets criteria and gives mgsbox.
This is what I have

What do you mean by "counts a fieldbox"?

I'm not aware of any Access construct called a "fieldbox".
It's not clear what you want to count: records on a table? controls in a Form?

Please explain the context.
 
J

jesseu via AccessMonster.com

John said:
What do you mean by "counts a fieldbox"?

I'm not aware of any Access construct called a "fieldbox".
It's not clear what you want to count: records on a table? controls in a Form?

Please explain the context.
Mr Vinson, sorry I meant txtbox inside txtbox2 is =Count([FirstName]) every
time txt is placed in [FirstName] txtbox2 counts it. After Update (Event
Procedure) txtbox2 I wrote
if ([Text2]) = 6 Then
MsgBox "CREATE LABEL "
Else
stDocName = "Labels "
DoCmd.OpenReport stDocName, acNormal
End If
End sub
Nothing happens, just getting started with code.
Thank you for replying
Jesse
 
J

John W. Vinson

John said:
What do you mean by "counts a fieldbox"?

I'm not aware of any Access construct called a "fieldbox".
It's not clear what you want to count: records on a table? controls in a Form?

Please explain the context.
Mr Vinson, sorry I meant txtbox inside txtbox2 is =Count([FirstName]) every
time txt is placed in [FirstName] txtbox2 counts it. After Update (Event
Procedure) txtbox2 I wrote
if ([Text2]) = 6 Then
MsgBox "CREATE LABEL "
Else
stDocName = "Labels "
DoCmd.OpenReport stDocName, acNormal
End If
End sub
Nothing happens, just getting started with code.
Thank you for replying
Jesse

Jesse, I'm sorry, but we're still not communicating. Remember: you can see
your screen. You know the structure of your database. Nobody out here knows
anything about it *except what you post*.

=Count([firstname])

means nothing to me. Is this in a Query? on a Form? What's the Recordsource of
the form? Where on the Form is it? What are you counting - records added to a
table?

Your code is not working because the AfterUpdate event of a textbox only fires
when its contents are changed by the user - not by code. So the afterupdate
event will never fire.

Step back a bit and explain, in English, what you are trying to accomplish -
rather than how you're (not) accomplishing it!
 
J

jesseu via AccessMonster.com

John said:
[quoted text clipped - 19 lines]
Thank you for replying
Jesse

Jesse, I'm sorry, but we're still not communicating. Remember: you can see
your screen. You know the structure of your database. Nobody out here knows
anything about it *except what you post*.

=Count([firstname])

means nothing to me. Is this in a Query? on a Form? What's the Recordsource of
the form? Where on the Form is it? What are you counting - records added to a
table?

Your code is not working because the AfterUpdate event of a textbox only fires
when its contents are changed by the user - not by code. So the afterupdate
event will never fire.

Step back a bit and explain, in English, what you are trying to accomplish -
rather than how you're (not) accomplishing it!

I have a form in this form user places FirstName in one textbox and Lastname
in a second textbox. Form Default View is Continuous Forms. In the form
Footer I place a Textbox ([txt1]) in the Control Source I place =Count(
[FirstName]) no problem counting every time a name gets added. I would like
to print a label when the count gets to a number I give it using one of the
Event Procedures under the Event Tab

Thanks Again
Jesse
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top