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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a trick to writing code to enable/disable fields?

Status
Not open for further replies.

Pete901

Technical User
Nov 28, 2000
1
US
My problem seems to be that I am trying to do this on a subform.

This is not a table type subform (its not the kind of subform that looks like an excel spread sheet), but rather a combobox and several other fields and all but the first are enabled = no. As the user fills in one field, the next one becomes available depending on certain criteria.


I have several problems:

For example - Record#1 on the subform.
If the first field has the right data, then you advance to the next field (which becomes enabled). If the data has been entered into the second field but does not meet the criteria to enable the 3rd field, it is time to create a new record on the subform. You then press the navigation button at the bottom of the form and advance to the next subform record. This is Record#2.
Problem is that the second field will be enabled on this record even though I have not filled out the required info in the first field.

I have tried the Form_Current event to help it stop the latter problem but then you are able to advance through new records without even entering in info. This creates a bunch of blank records. The minute I remove the Call from the Form_Current (the call to the AfterUpdate event that was written to enable/disable the fields), the extra blank records problems go away.

Does any one understand my problem and if so, is there a solution to it?

I can sort of write code but I seem to be missing some important stuff here. Please help if you can.
 
Hi Pete,

No, but there are some limitations (oh great you say!)

in this situation you might like to re-think how to acheive your aim for instance you want to start with all but the first field locked if i presume correctly. create a function called by the subforms On Current event that "sets up an empty form ie unlocks the initial field and locks all others, then if the user changes the "current record" the function will loock the controls. you will also have to consider the data entry state of the form when the user goes to other records. this could be an extension of the control function ie other sub functions, which may be called from the after update event of the various controls on the form.

HTH


Robert Dwyer
rdwyer@orion-online.com.au
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top