Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to reset the value of a control

Status
Not open for further replies.

hawkeye71

Technical User
Feb 9, 2001
45
US
Hi,
I am using MS Access 2000.
I have created a form from only ONE table.
The form contains one drop down field, which can have only two values; A or B. This drop down is also from the same table.
If I select A, I can enter data in fields G, H, and I.
If I select B, I can enter data in fields C, D, and E.
While entering data for G, H, and I, if I switch from A to B, I want the values of the fields G, H, and I reset to 0.
Similarly if I switch to B to A, while I am entering data in C, D, and E, the values of the fields C, D, and E should reset to 0.
I have tried to use the "Change", "Exit" and "LostFocus" functions of the field that holds the A and B information, and tried to set the value of the fields C,D,E or G,H,I to 0, but I get the following error:
"You can't reference a property or method for a control unless the control has the focus".
If thats the case I have to give focus to each field before I set its value to 0, is this the only way to proceed?
All the help is welcome and appreciated.


Thanks,
Indiana
 
You need the Afterupdate event for the combobox.

sub mycombo_afterupdate()
if me.mycombo = "A" then
me.C = 0
me.c.enabled = false
me.D = 0
me.D.enabled = false
me.E= 0
me.E.enabled = false

else......
 
Thanks for the quick response. I believe it should work.
Is "me" the name of the Form?



Thanks,
Indiana
 
'me' is a reference to the object which contains this code.

Since this procedure must go in the form module it does refer to the form. You don't have to change it to anything else.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top