set focus method

  • Thread starter Thread starter who can help me
  • Start date Start date
W

who can help me

I created a form with a test boxt and command buttom. I need a situation when
I click on the command buttom, specified amount which i have put inside my
coode should appear in the text box. when i wrote this code and run computer
was giiven me this error:
You can reference a property or method for a control unless you the control
has a focus

My code
Private Sub optWith_Meal_Click()
txtAmount.Text = 5000
End Sub

what can I do
 
You can't reference the text property if the textbox has not got the focus.
In this case you don't need to anyway
Private Sub optWith_Meal_Click()
txtAmount = 5000
End Sub
 
RonaldoOneNil said:
You can't reference the text property if the textbox has not got the focus.
In this case you don't need to anyway
Private Sub optWith_Meal_Click()
txtAmount = 5000
End Sub


that you I tried it and it work. but other thing,
(1)how can i set a focus a command
when I unclick the option buttom i want the amonut 5000 to disapper that is
the text box should cbe empty
 
who can help me said:
thank you I tried it and it work. but other thing,
(1)how can i set a focus for a command
(2)when I uclick again the option buttom, i want the amonut 5000 to disapper that is
the text box should be empty
 
Back
Top