How do you SetValue a field to a text string?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a button on my form and I want to attach a text string to it when
someone clicks on it. I'm not sure if I need a macro or an something in the
event property.

Thanks
 
attach a text string to it and do what? Copy and paste, enter data into
another field? Please explain more your intention and we'll be able to help.

Daniel
 
like Daniel says, more information required. However, if you want a text
label to appear when the button is pressed or the the text to change when the
button is pressed, you can add a text string to your form. Lets assume that
you want the text string to change what it says when you press the button.
The text label generated lets say reads "Button Not Pressed"

Right click the text label with the form in design mode and select
properties. Change the label name to something like ButtonTxt (Top box in the
all tab). you will see the caption value "Button Not Pressed"

Now right click the button and select the on click event. Underneath the
code that is already there but above the exit command type

Me.ButtonTxt.Visible = True
Me.ButtonTxt.Caption = "Button Pressed"

(This assumes that you have made the button using the wizard, the example
below uses a add new record button generated using the wizard)

Private Sub Command15_Click()
On Error GoTo Err_Command15_Click


DoCmd.GoToRecord , , acNewRec

Me.ButtonTxt.Visible = True
Me.ButtonTxt.Caption = "Button Pressed"

Exit_Command15_Click:
Exit Sub

Err_Command15_Click:
MsgBox Err.Description
Resume Exit_Command15_Click

End Sub

If you just have a button that you have cancelled the wizard on, again click
on the on click event and add the following.

Me.ButtonTxt.Visible = True 'Makes the text Visible
Me.ButtonTxt.Caption = "Button Pressed" 'Changes the text Value

As shown below

Private Sub Command17_Click()
Me.ButtonTxt.Visible = True 'Makes the text Visible
Me.ButtonTxt.Caption = "Button Pressed" 'Changes the text Value
End Sub

If this is not what you wanted to do, please explain some more.

Mike

--
An Engineers Prayer:
At the very end of the day,
when all else fails,
you have tried all
and asked everyone you know,
read the instruction manual.
 
What I'm looking to do is when the button is clicked, in another field, I
want to add a text string. The button is called "Please call me to discuss"
and when the user clicks it, I want a message to appear in the "comment"
field (in the table) to call the user.

I would appreciate any help you can give. Thanks.
 
Sorry, forgot to mention, you need another event to re-change the text value,
maybe something like, in the on got focus event of the form, set the text to
one value or make it invisible and then set the new value and make it visible
on your button command as previous reply.
--
An Engineers Prayer:
At the very end of the day,
when all else fails,
you have tried all
and asked everyone you know,
read the instruction manual.
 
Another question, is the comment control on the form? If it is, in on click
event of the button type as follows.

Private Sub Command17_Click()
Me.Comment.Value = "Call Me"
End Sub

Remember you can add the comment fiel to the form and set it to not visible
if you don't want it to be seen

If the comment fiels is elsewhere in a different table then you will need
more code. But this is a quick answer assuming that it is on the form.


--
An Engineers Prayer:
At the very end of the day,
when all else fails,
you have tried all
and asked everyone you know,
read the instruction manual.
 

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

Back
Top