Hello,
Looking for an easier and cleaner way to put in some code.
If there's not, never mind ill keep copy and pasting. :-(
I have a form, multiple check boxes. when ticked puts in date in text box.
when unticked asks if your sure then removes date and tick.
I have sooooooo many Checkboxes that require this function.
Is there an easier/cleaner way to code these?
thank you
example of code
And also in the Form Current
Looking for an easier and cleaner way to put in some code.
If there's not, never mind ill keep copy and pasting. :-(
I have a form, multiple check boxes. when ticked puts in date in text box.
when unticked asks if your sure then removes date and tick.
I have sooooooo many Checkboxes that require this function.
Is there an easier/cleaner way to code these?
thank you
example of code
Code:
'------------------------------------------------------------
' Check Boxes - Fill in dates and remove dates
'
'------------------------------------------------------------
Private Sub ChkIFA_Sent_Click()
If ChkIFA_Sent = True Then
Form_JobDetailF.TxtIFA_Sent = Date
TxtIFA_Sent.Enabled = False
Else
Dim iResponse As String
iResponse = MsgBox("Are you sure you want to remove the IFA sent date?", vbYesNo)
Select Case iResponse
Case vbYes:
Form_JobDetailF.TxtIFA_Sent = ""
TxtIFA_Sent.Enabled = True
Case vbNo:
ChkIFA_Sent = True
End Select
End If
End Sub
Private Sub ChkIFC_Complete_Click()
If ChkIFC_Sent = True Then
Form_JobDetailF.TxtIFC_Complete = Date
TxtIFC_Complete.Enabled = False
Else
Dim iResponse As String
iResponse = MsgBox("Are you sure you want to remove the IFC complete date?", vbYesNo)
Select Case iResponse
Case vbYes:
Form_JobDetailF.TxtIFC_Complete = ""
TxtIFC_Complete.Enabled = True
Case vbNo:
ChkIFC_Sent = True
End Select
End If
End Sub
Private Sub ChkSample_Sent_Click()
If ChkSample_Sent = True Then
Form_JobDetailF.TxtSample_Sent = Date
TxtSample_Sent.Enabled = False
Else
Dim iResponse As String
iResponse = MsgBox("Are you sure you want to remove the Sample sent date?", vbYesNo)
Select Case iResponse
Case vbYes:
Form_JobDetailF.TxtSample_Sent = ""
TxtSample_Sent.Enabled = True
Case vbNo:
ChkSample_Sent = True
End Select
End If
End Sub
And also in the Form Current
Code:
Private Sub Form_Current()
'Checking CheckBoxes for true/false and dates
If ChkIFA_Sent = True Then
Form_JobDetailF.TxtIFA_Sent = Date
TxtIFA_Sent.Enabled = False
Else
Form_JobDetailF.TxtIFA_Sent = ""
TxtIFA_Sent.Enabled = True
End If
'_______________________________________________
If ChkIFC_Sent = True Then
Form_JobDetailF.TxtIFC_Complete = Date
TxtIFC_Complete.Enabled = False
Else
Form_JobDetailF.TxtIFC_Complete = ""
TxtIFC_Complete.Enabled = True
End If
'_______________________________________________
If ChkSample_Sent = True Then
Form_JobDetailF.TxtSample_Sent = Date
TxtSample_Sent.Enabled = False
Else
Form_JobDetailF.TxtSample_Sent = ""
TxtSample_Sent.Enabled = True
End If
'_______________________________________________
End Sub