S
sunilkeswani
Hi
I got this code to work on basis of a text box afterupdate, but how do
I do a similar action for a check box, if checked, makes a particular
field visible and mandatory to fill?
Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.txt) Then
Select Case Me.txt2.Value
Case 115, 158, 160
Cancel = True
MsgBox "txt is required."
End Select
End If
End Sub
To make it visible, use the AfterUpdate of txt2. You also need to do
this in
the Current event of the form, so it is visible/hidden when the form
moves
record:
Private Sub txt2_AfterUpdate
Dim bShow As Boolean
Select Case Me.txt2.Value
Case 115, 158, 160
bShow = True
End Select
With Me.txt
If .Visible <> bShow Then
.Visible = bShow
End If
End With
End Sub
Private Sub Form_Current()
Call txt2_AfterUpdate
End Sub
Above code was courtesy Allen, now I need some more help.
Cheers
Sunny
I got this code to work on basis of a text box afterupdate, but how do
I do a similar action for a check box, if checked, makes a particular
field visible and mandatory to fill?
Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.txt) Then
Select Case Me.txt2.Value
Case 115, 158, 160
Cancel = True
MsgBox "txt is required."
End Select
End If
End Sub
To make it visible, use the AfterUpdate of txt2. You also need to do
this in
the Current event of the form, so it is visible/hidden when the form
moves
record:
Private Sub txt2_AfterUpdate
Dim bShow As Boolean
Select Case Me.txt2.Value
Case 115, 158, 160
bShow = True
End Select
With Me.txt
If .Visible <> bShow Then
.Visible = bShow
End If
End With
End Sub
Private Sub Form_Current()
Call txt2_AfterUpdate
End Sub
Above code was courtesy Allen, now I need some more help.
Cheers
Sunny