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

Command Button to insert text into field

Status
Not open for further replies.

jmbcreative

Technical User
Jan 30, 2006
58
US
I have a simple task. I need a command button to insert text into a couple of fields when pressed. What is the on-click syntax to do so?

My inclination is to use
******

Private Sub Approve_Click()
Me.Status.Value = "Approved"
Me.Approval.Value = "Y"

******

But for some reason it is not working. Any ideas?
 
the syntax is correct.

if this is executed right before a LONG loop is performed or something, it wont be updated until after that loops has finished...unless you add the line
DoEvents
after changing the values.

But this is only if you have something else going on when you click approve.

****

Another suggestion is to change the control name value instead of the field it is linked to. Say Me.Status is stored in the control txtStatus...then use txtStatus instead.

-Pete
 
Thanks Pete.

How do I use the DoEvents syntax?

I do have other event procedures going on. Basically on click I want to enter the text in the firelds, then I run an append query that appends those records that I inserted the text into and then I have a requery procedure on mouse up. It's a little complicated.
 
just do

Private Sub Approve_Click()
Me.Status.Value = "Approved"
Me.Approval.Value = "Y"
DoEvents

...the rest of your code

-Pete
 
How are ya jmbcreative . . .

If the button is on a mainform and the texboxes are on a subform . . . or viceversa, you'll have to include [blue]form referencing[/blue] . . .

Calvin.gif
See Ya! . . . . . .
 
Got it figured out. I used the DoEvents in my syntax.

Thank ya much. =)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top