Enabling text box based on data in other text box

danson

Registered User.
Local time
Tomorrow, 06:17
Joined
Apr 6, 2004
Messages
15
Hi All

Looking for some quick help
I have a form made from the data in a table and what I would like to do is

if the data in one txt box = 1 than only the data1 text box would be available for edit,

if the data in one txt box = 2 than only the data2 text box would be available for edit,

and so on

below is the code I have entered on the on open event of the form

Private Sub Form_Open(Cancel As Integer)

If DataTypes = 1 Then
Data1.Enabled = True
Else
Data1.Enabled = False
End If

If DataTypes = 2 Then
Data2.Enabled = True
Else
Data2.Enabled = False
End If

If DataTypes = 3 Then
Data3.Enabled = True
Else
Data3.Enabled = False
End If
End Sub

Any help would be fantastic

Thanks
danson
 
Put the code in the DataTypes textbox's After Update, On Exit, or On Lost Focus event.
Also a SELECT CASE statement would be better than multiple IF's
eg
Code:
Data1.Enabled = False
Data2.Enabled = False
...etc etc...

Select Case DataTypes
    Case 1
        Data1.Enabled
    Case 2
    ...etc etc...
End Select
 
Thanks

Will try the select case statement - I did try code in the after update with no success. The text box datatype will have pre defined data in it eg 1, 2, 3 and I only want the corresponding textbox eg Data1 to be enabled. This is so the user only puts data in the entry field they are ment to.
Hope this makes sence.
I think i nearly have it doing what I want


danson
 
I am attaching a sample in case someone else needs this help. May not be the best way to do it but it works.

danson
 

Attachments

Users who are viewing this thread

Back
Top Bottom