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

How to conditionally lock a series of fields 2

Status
Not open for further replies.

SteveCop

Programmer
Jan 11, 2002
24
0
0
GB
One of the forms on my database contains a five tab page. There are around 20 fields on each page and each page is pretty well a mirror of the others, the data fields on page 1 being identified with trailers of _1, on page 2 _2 etc. For each page there is a database field called IsLocked. When true I want IsLocked_2, for example, to lock certain fields on page 2.

I had success with page 1 using the following code:

(Form on Current procedure)
IF Me![IsLocked_1] = True then
Sales_1.enabled = false
SalesDates_1.enabled = false
EndIf

I am, though, having a problem getting the same code to work for the subsequent pages. When I copy this code for Page 2 then, on opening the form, I get the error message "Compile Error; Method or Data Member not found", the Sales_2.enabled = false line being highlighted.

Am I wrong in trying to conditionally lock fields in this way? If I use an "on Enter" property to set the field as non-enabled this gives an error advising you cannot change the properties of the field whilst it has focus.

Sorry for the long post - can someone tell me where I am going wrong please!

 
you could use the tab control change property. You could use a select case to know which tab is been pressed, and then decide what field to enable or un-enable etc.

if you want any more help let me know.
 
I am an idiot! Sorry to waste anyone's valuable time!

I was using the field names in the code, not the actual control names. (shuffles off into the distance in shame)
 
M8KWR

Thanks for your suggestion. Although I know what I did wrong (see previous shame faced post) I like your idea as it will help me elsewhere. I am already using tab control change property for another purpose but did not know it was possible to work out which particular tab had been pressed. Could you guide me please on how the select case statement would work?
 
Here you go: -

Code:
Private Sub TABNAME_Change()


Select Case TABNAME.Value


Case 0      'Page1


Case 1      'Page2


Case 2      'Page3


End Select


End Sub

Hope this helps. Do not forget that in the code the page number is always 1 more then the value...
 
Take a look at the Pages collection of the TabControl object.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top