I’m absolutely sure I’m doing this the hard way. The following code is driving me crazy. It works okay, but is a programming nightmare. I seem to always have to do things the hard way. Is there a better way of coding the below arguments? All I want is to have certain text boxes visible/not visible. The same goes for enable/disable. Can anyone give me a few pointers?
Option Compare Database
Private Sub cmdDateNotif_Click()
txtDateNotified.Value = Now()
End Sub
Private Sub cmdDateRec_Click()
txtDateRec.Value = Now()
End Sub
Private Sub cmdPostedDate_Click()
txtPostingDate.Value = Now()
End Sub
Private Sub cmdHoldDate_Click()
txtHoldDate.Value = Now()
End Sub
Private Sub Form_Current()
If chkNotified.Value = True Then txtDateNotified.Visible = True Else cmdDateNotif.Visible = False
If chkNotified.Value = False Then txtDateNotified.Visible = False Else cmdDateNotif.Visible = True
If chkPosted.Value = True Then txtPostingDate.Visible = True Else cmdPostedDate.Visible = False
If chkPosted.Value = False Then txtPostingDate.Visible = False Else cmdPostedDate.Visible = True
If chkHold.Value = True Then txtHoldDate.Visible = True Else cmdHoldDate.Visible = False
If chkHold.Value = False Then txtHoldDate.Visible = False Else cmdHoldDate.Visible = True
If chkNotified.Value = True Then txtDateNotified.Visible = True Else txtDateNotified.Visible = False
If chkPosted.Value = True Then txtPostingDate.Visible = True Else txtPostingDate.Visible = False
If chkHold.Value = True Then txtHoldDate.Visible = True Else txtHoldDate.Visible = False
Me.Staff.Value = Forms!frmStaffInfo!StaffID
End Sub
Private Sub Form_Load()
If chkNotified.Value = True Then txtDateNotified.Visible = True Else cmdDateNotif.Visible = False
If chkPosted.Value = True Then txtPostingDate.Visible = True Else cmdPostedDate.Visible = False
If chkHold.Value = True Then txtHoldDate.Visible = True Else cmdHoldDate.Visible = False
If chkNotified.Value = True Then txtDateNotified.Visible = True Else txtDateNotified.Visible = False
If chkPosted.Value = True Then txtPostingDate.Visible = True Else txtPostingDate.Visible = False
If chkHold.Value = True Then txtHoldDate.Visible = True Else txtHoldDate.Visible = False
Me.Staff.Value = Forms!frmStaffInfo!StaffID
End Sub
Private Sub chkNotified_Click()
If chkNotified.Value = True Then txtDateNotified.Visible = True Else cmdDateNotif.Visible = False
If chkNotified.Value = True Then txtDateNotified.Visible = True Else txtDateNotified.Visible = False
If chkNotified.Value = False Then txtDateNotified.Visible = False Else cmdDateNotif.Visible = True
If chkNotified.Value = False Then txtDateNotified.Visible = False Else txtDateNotified.Visible = True
End Sub
Private Sub chkPosted_Click()
If chkPosted.Value = True Then txtPostingDate.Visible = True Else cmdPostedDate.Visible = False
If chkPosted.Value = True Then txtPostingDate.Visible = True Else txtPostingDate.Visible = False
If chkPosted.Value = False Then txtPostingDate.Visible = False Else cmdPostedDate.Visible = True
If chkPosted.Value = False Then txtPostingDate.Visible = False Else txtPostingDate.Visible = True
End Sub
Private Sub chkHold_Click()
If chkHold.Value = True Then txtHoldDate.Visible = True Else cmdHoldDate.Visible = False
If chkHold.Value = True Then txtHoldDate.Visible = True Else txtHoldDate.Visible = False
If chkHold.Value = False Then txtHoldDate.Visible = False Else cmdHoldDate.Visible = True
If chkHold.Value = False Then txtHoldDate.Visible = False Else txtHoldDate.Visible = True
End Sub
Option Compare Database
Private Sub cmdDateNotif_Click()
txtDateNotified.Value = Now()
End Sub
Private Sub cmdDateRec_Click()
txtDateRec.Value = Now()
End Sub
Private Sub cmdPostedDate_Click()
txtPostingDate.Value = Now()
End Sub
Private Sub cmdHoldDate_Click()
txtHoldDate.Value = Now()
End Sub
Private Sub Form_Current()
If chkNotified.Value = True Then txtDateNotified.Visible = True Else cmdDateNotif.Visible = False
If chkNotified.Value = False Then txtDateNotified.Visible = False Else cmdDateNotif.Visible = True
If chkPosted.Value = True Then txtPostingDate.Visible = True Else cmdPostedDate.Visible = False
If chkPosted.Value = False Then txtPostingDate.Visible = False Else cmdPostedDate.Visible = True
If chkHold.Value = True Then txtHoldDate.Visible = True Else cmdHoldDate.Visible = False
If chkHold.Value = False Then txtHoldDate.Visible = False Else cmdHoldDate.Visible = True
If chkNotified.Value = True Then txtDateNotified.Visible = True Else txtDateNotified.Visible = False
If chkPosted.Value = True Then txtPostingDate.Visible = True Else txtPostingDate.Visible = False
If chkHold.Value = True Then txtHoldDate.Visible = True Else txtHoldDate.Visible = False
Me.Staff.Value = Forms!frmStaffInfo!StaffID
End Sub
Private Sub Form_Load()
If chkNotified.Value = True Then txtDateNotified.Visible = True Else cmdDateNotif.Visible = False
If chkPosted.Value = True Then txtPostingDate.Visible = True Else cmdPostedDate.Visible = False
If chkHold.Value = True Then txtHoldDate.Visible = True Else cmdHoldDate.Visible = False
If chkNotified.Value = True Then txtDateNotified.Visible = True Else txtDateNotified.Visible = False
If chkPosted.Value = True Then txtPostingDate.Visible = True Else txtPostingDate.Visible = False
If chkHold.Value = True Then txtHoldDate.Visible = True Else txtHoldDate.Visible = False
Me.Staff.Value = Forms!frmStaffInfo!StaffID
End Sub
Private Sub chkNotified_Click()
If chkNotified.Value = True Then txtDateNotified.Visible = True Else cmdDateNotif.Visible = False
If chkNotified.Value = True Then txtDateNotified.Visible = True Else txtDateNotified.Visible = False
If chkNotified.Value = False Then txtDateNotified.Visible = False Else cmdDateNotif.Visible = True
If chkNotified.Value = False Then txtDateNotified.Visible = False Else txtDateNotified.Visible = True
End Sub
Private Sub chkPosted_Click()
If chkPosted.Value = True Then txtPostingDate.Visible = True Else cmdPostedDate.Visible = False
If chkPosted.Value = True Then txtPostingDate.Visible = True Else txtPostingDate.Visible = False
If chkPosted.Value = False Then txtPostingDate.Visible = False Else cmdPostedDate.Visible = True
If chkPosted.Value = False Then txtPostingDate.Visible = False Else txtPostingDate.Visible = True
End Sub
Private Sub chkHold_Click()
If chkHold.Value = True Then txtHoldDate.Visible = True Else cmdHoldDate.Visible = False
If chkHold.Value = True Then txtHoldDate.Visible = True Else txtHoldDate.Visible = False
If chkHold.Value = False Then txtHoldDate.Visible = False Else cmdHoldDate.Visible = True
If chkHold.Value = False Then txtHoldDate.Visible = False Else txtHoldDate.Visible = True
End Sub