Text Property problem

  • Thread starter Thread starter harrymahal
  • Start date Start date
H

harrymahal

Guest
Hi...

I am using Access for the first time and am having trouble.

I have to set up a form containing a Text Box, A Label and a Button. I have to write a Caption on the Label asking the user to enter a name. Also I have to edit the Text Box's Text Property to leave it blank. I do not know how to do this.

The code attached to the button is:

Private Sub Command1_Click()
Label1.Caption = Text1.Text
End Sub

So when I clcik on the button, the Label should display the user's name.

But I keep getting an error:

Run-time error '2185':

You can't reference a proerty or method for a control unless the control has the focus.

I don't know what this error means....

Please help.....as I am just a beginner

Thankyou in advance

Harry
 
If you use refer to the Text property of the text box, it will have to have the focus to perform this function. The following would work...

Private Sub Command1_Click()
Text1.SetFocus
Label1.Caption = Text1.Text
End Sub

The Text property is the default property of a text box, so if you don't want to set the focus to the text box, use the following...

Private Sub Command1_Click()
Label1.Caption = Text1
End Sub

Good luck!



[This message has been edited by scottfarcus (edited 10-28-2001).]
 

Users who are viewing this thread

Back
Top Bottom