PC Review


Reply
Thread Tools Rate Thread

Command Buttons again

 
 
=?Utf-8?B?Y29hc3RhbA==?=
Guest
Posts: n/a
 
      23rd Aug 2006
Trying to get a command button to concatenate values in two text boxes and
display it on to a label on the same form.

I have
Private Sub cmdDisplay_Click()
lblFullName.Caption = txtFirst.Text & txtLast.Text
End Sub

I get an error saying the control needs to have the focus, but I have
references to two controls (txtFirst and txtLast).

Is there a fix?
--
--coastal
 
Reply With Quote
 
 
 
 
fredg
Guest
Posts: n/a
 
      23rd Aug 2006
On Wed, 23 Aug 2006 14:16:02 -0700, coastal wrote:

> Trying to get a command button to concatenate values in two text boxes and
> display it on to a label on the same form.
>
> I have
> Private Sub cmdDisplay_Click()
> lblFullName.Caption = txtFirst.Text & txtLast.Text
> End Sub
>
> I get an error saying the control needs to have the focus, but I have
> references to two controls (txtFirst and txtLast).
>
> Is there a fix?


In Access, it's a control's Value property you need to use, not it's
text property.
Look them up in VBA help to learn the difference.

Because the Value property is the control's default, you do not need
to state it:

lblFullName.Caption = txtFirst & txtLast

Note: Don't you want a space between the 2 names?
lblFullName.Caption = txtFirst & " " & txtLast
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Form buttons and Control Command Buttons ranswrt Microsoft Excel Programming 0 7th Aug 2008 11:36 PM
Command Buttons Jay Dawg Microsoft Access 3 18th Jul 2008 08:48 PM
Command Buttons jo2389hn Microsoft Excel Discussion 1 18th Jul 2005 06:53 PM
Command Buttons =?Utf-8?B?UmFjaGVs?= Microsoft Access Forms 0 17th Sep 2004 08:41 PM
Control Buttons vs. Command Buttons Robert Gibson Microsoft Excel Programming 1 13th Oct 2003 04:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:49 PM.