pass a str value to a variable

R

Renee

In the OnCurrent state of my form, if the value of my text
box [txtDistrict] equals "suspend", I want to disable a
command butoon. How do I pass the value of txtReturn
field to a variable to use in an IF/THEN statement to set
my button to Enabled = False.

My button should always be active unless the field
[txtDistrict] = "suspend" (I could use "Enabled"
or "Visible" - really won't matter)

Thanks you for your help - Renee
 
S

Scott McDaniel

In the OnCurrent event of your form:

If Me.txtDistrict = "suspend" then
Me.NameofYourButton.Enabled = False
Else
Me.nameOfYourButton.Enabled = True
End If
 
A

Andrew Smith

The following code will change the enabled property of the button (I've
called the button cmdButton):

Me.cmdButton.Enabled = Not (Me.txtDistrict = "Suspend")

(Or you could put:

If Me.txtDistrict = "Suspend" then
Me.cmdButton.Enabled = False
Else
Me.cmdButton.Enabled = True)

I'm not sure if the current event would be the right one to use - I'd have
thought that the AfterUpdate event of the text box would normally be the one
to use for this, but then I don't know what you're trying to do. To use the
current event of the form, open the form property sheet, click the event tab
then select "Event Procedure" from the drop down list next to OnCurrent.
Click the ... next to the list to launch the VB editor, and then type in the
code. (To use the AfterUpdate event of the text box use the property sheet
for the control).
 

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

Top