Hi Jon
Open the sub form in design view and then right click the text box (text1)
to open the properties box
Set the Enabled row to No
Do the same for all the other boxes
Save and close
Open the main form in design view - and then right click the Code box to
open the properties box
Add this to the AfterUpdate (just to test the code) - you can change the
event later.
Private Sub Code_AfterUpdate()
If Me.Code = 1 Then
Forms![MainForm]![SubForm].Form![Text1].Enabled = True
Forms![MainForm]![SubForm].Form![Text2].Enabled = False
Forms![MainForm]![SubForm].Form![Text3].Enabled = False
Forms![MainForm]![SubForm].Form![Text4].Enabled = False
Forms![MainForm]![SubForm].Form![Text5].Enabled = False
ElseIf Me.Code = 2 Then
Forms![MainForm]![SubForm].Form![Text2].Enabled = True
Forms![MainForm]![SubForm].Form![Text1].Enabled = False
Forms![MainForm]![SubForm].Form![Text3].Enabled = False
Forms![MainForm]![SubForm].Form![Text4].Enabled = False
Forms![MainForm]![SubForm].Form![Text5].Enabled = False
ElseIf Me.Code = 3 Then
Forms![MainForm]![SubForm].Form![Text3].Enabled = True
Forms![MainForm]![SubForm].Form![Text1].Enabled = False
Forms![MainForm]![SubForm].Form![Text2].Enabled = False
Forms![MainForm]![SubForm].Form![Text4].Enabled = False
Forms![MainForm]![SubForm].Form![Text5].Enabled = False
ElseIf Me.Code = 4 Then
Forms![MainForm]![SubForm].Form![Text4].Enabled = True
Forms![MainForm]![SubForm].Form![Text1].Enabled = False
Forms![MainForm]![SubForm].Form![Text2].Enabled = False
Forms![MainForm]![SubForm].Form![Text3].Enabled = False
Forms![MainForm]![SubForm].Form![Text5].Enabled = False
ElseIf Me.Code = 5 Then
Forms![MainForm]![SubForm].Form![Text5].Enabled = True
Forms![MainForm]![SubForm].Form![Text1].Enabled = False
Forms![MainForm]![SubForm].Form![Text2].Enabled = False
Forms![MainForm]![SubForm].Form![Text3].Enabled = False
Forms![MainForm]![SubForm].Form![Text5].Enabled = False
End If
End Sub
You do need to add all the lines so that if you change the number in the
Code:
then you will (I assume) want the other text box to become disabled.
I am not sure if the word "Code" is restricted and it is not really a good
idea to call your text boxes 1 2 3 etc. Give them a name that means something
Good luck