Hi all, hope you can help.
I have a user input form, on which there are two option buttons. On selecting either, I have the code to blank out certain other N/A input fields (turn red and N/A in the field). Speeds up data input by blanking out fields of no importance for the user. This works. Code below:
*******************************************************************
'Option button to mark out unwanted fields
Private Sub optRailPort_Click()
Me.cboVess.Text = ""
Me.cboVess.Enabled = False
Me.txtTMode.Text = ""
Me.txtTMode.Enabled = True
If cboVess.Enabled = False Then cboVess.BackColor = vbRed
' to place N/A in disabled field
If cboVess.Enabled = False Then cboVess.Text = "N/A"
If txtTMode.Enabled = True Then txtTMode.Text = "Rail"
'to clear other option from use
If optRailPort.Enabled = True Then
Me.optSeaPort.Visible = False
End If
End Sub
************************************************************************
I now wish to expand this idea where a user selects a particular entry in a Combo Box. There are two possibilities in the ComboBox, "Accompanied" and " Unaccompanied". Where "Unaccompanied" is selected I wish a user input text field, 'Nam2', to be blanked vbRed and have N/A as text entered in that field. Where "Accompanied" is selected I wish no action to be taken with the Nam2 field.
I have been playing with this code to try and get it to work:
'**************************************************
'to blank out Accompanied Adult if pax is unaccompanied
'Private Sub Accompanied_Change()
'Me.Accompanied.Text = "Unnaccompanied"
'Me.Nam2.Text = ""
'If Accompanied.Enabled = "Unnaccompanied" Then Nam2.BackColor = vbRed
'End Sub
'********************************************************
Any help please
I have a user input form, on which there are two option buttons. On selecting either, I have the code to blank out certain other N/A input fields (turn red and N/A in the field). Speeds up data input by blanking out fields of no importance for the user. This works. Code below:
*******************************************************************
'Option button to mark out unwanted fields
Private Sub optRailPort_Click()
Me.cboVess.Text = ""
Me.cboVess.Enabled = False
Me.txtTMode.Text = ""
Me.txtTMode.Enabled = True
If cboVess.Enabled = False Then cboVess.BackColor = vbRed
' to place N/A in disabled field
If cboVess.Enabled = False Then cboVess.Text = "N/A"
If txtTMode.Enabled = True Then txtTMode.Text = "Rail"
'to clear other option from use
If optRailPort.Enabled = True Then
Me.optSeaPort.Visible = False
End If
End Sub
************************************************************************
I now wish to expand this idea where a user selects a particular entry in a Combo Box. There are two possibilities in the ComboBox, "Accompanied" and " Unaccompanied". Where "Unaccompanied" is selected I wish a user input text field, 'Nam2', to be blanked vbRed and have N/A as text entered in that field. Where "Accompanied" is selected I wish no action to be taken with the Nam2 field.
I have been playing with this code to try and get it to work:
'**************************************************
'to blank out Accompanied Adult if pax is unaccompanied
'Private Sub Accompanied_Change()
'Me.Accompanied.Text = "Unnaccompanied"
'Me.Nam2.Text = ""
'If Accompanied.Enabled = "Unnaccompanied" Then Nam2.BackColor = vbRed
'End Sub
'********************************************************
Any help please