Hello,
I have a problem with my dates field on a form,
I have text boxes that when are clicked, Access puts in this__/__/__ in the text box. I'd like for when a user clicks on the text box, the cursor to start at the very beggining, so in this case the first __/ and not the third __/
and when the date is populated on the first text box, I want the cursor to move to the second text box and again start at the beginning __/
I've never done that before. Can I get any help from you?
My existing code in the form is ;
Private Sub cmdEnter_Click()
Dim strWhere1 As String
Dim strReportName As String
strReportName = "rptmain"
strWhere1 = ""
'Check Requirements
If IsNull(Me.txtDate1) And Not IsNull(Me.txtDate2) Then
MsgBox "Enter a start date", vbExclamation
Exit Sub
ElseIf Not IsNull(Me.txtDate1) And IsNull(Me.txtDate2) Then
MsgBox "Enter an end date.", vbExclamation
Exit Sub
End If
'Date Check
If IsNull(Me.txtDate1) And IsNull(Me.txtDate2) Then
strWhere1 = ""
Else
'strWhere1 = "[tblStatutes.Last_Reviewed_Date] Between #" & Me.txtDate1 & "# And #" & Me.txtDate2 & "#"
'orignal - strWhere1 = "[tblStatutes.Last_Reviewed_Date] Between #" & Me.txtDate1 & "# And #" & Me.txtDate2 & "#" & " OR " & "[tblStatutes.Effective_Date] Between #" & Me.txtDate1 & "# And #" & Me.txtDate2 & "#"
strWhere1 = "[Last_Reviewed_Date] Between #" & Me.txtDate1 & "# And #" & Me.txtDate2 & "#" & " OR " & "[Effective_Date] Between #" & Me.txtDate1 & "# And #" & Me.txtDate2 & "#"
' strWhere1 = "tblStatutes.Last_Reviewed_Date Between #" & Format(Me!txtDate1, "yyyy-mm-dd") & "# And #" & Format(Me!txtDate2, "yyyy-mm-dd") & "#"
End If
'Debug.Print strWhere1
'Combo 1
If IsNull(Me.cboType) Then
strWhere1 = strWhere1
Else
If strWhere1 = "" Then
strWhere1 = "[tblStatutes].[Type] = '" & Me.cboType & "'"
Else
strWhere1 = strWhere1 & " AND [tblStatutes].[Type] = '" & Me.cboType & "'"
End If
End If
'Debug.Print strWhere1
'Combo 2
If IsNull(Me.cboFunction) Then
strWhere1 = strWhere1
Else
If strWhere1 = "" Then
strWhere1 = "[tblStatutes].[Function_Type] = '" & Me.cboFunction & "'"
Else
strWhere1 = strWhere1 & " AND [tblStatutes].[Function_Type] = '" & Me.cboFunction & "'"
End If
End If
'Combo 3
If IsNull(Me.cboExemption_Status) Then
strWhere1 = strWhere1
Else
If strWhere1 = "" Then
strWhere1 = "[tblStatutes].[Exemption_Status] = '" & Me.cboExemption_Status & "'"
Else
strWhere1 = strWhere1 & " AND [tblStatutes].[Exemption_Status] = '" & Me.cboExemption_Status & "'"
End If
End If
'Debug.Print strWhere1
On Error Resume Next
DoCmd.OpenReport strReportName, acViewPreview, , strWhere1
Me.txtDate1 = Null
Me.txtDate2 = Null
Me.cboType = Null
Me.cboFunction = Null
Me.cboExemption_Status = Null
End Sub
Thanks,
Rita
I have a problem with my dates field on a form,
I have text boxes that when are clicked, Access puts in this__/__/__ in the text box. I'd like for when a user clicks on the text box, the cursor to start at the very beggining, so in this case the first __/ and not the third __/
and when the date is populated on the first text box, I want the cursor to move to the second text box and again start at the beginning __/
I've never done that before. Can I get any help from you?
My existing code in the form is ;
Private Sub cmdEnter_Click()
Dim strWhere1 As String
Dim strReportName As String
strReportName = "rptmain"
strWhere1 = ""
'Check Requirements
If IsNull(Me.txtDate1) And Not IsNull(Me.txtDate2) Then
MsgBox "Enter a start date", vbExclamation
Exit Sub
ElseIf Not IsNull(Me.txtDate1) And IsNull(Me.txtDate2) Then
MsgBox "Enter an end date.", vbExclamation
Exit Sub
End If
'Date Check
If IsNull(Me.txtDate1) And IsNull(Me.txtDate2) Then
strWhere1 = ""
Else
'strWhere1 = "[tblStatutes.Last_Reviewed_Date] Between #" & Me.txtDate1 & "# And #" & Me.txtDate2 & "#"
'orignal - strWhere1 = "[tblStatutes.Last_Reviewed_Date] Between #" & Me.txtDate1 & "# And #" & Me.txtDate2 & "#" & " OR " & "[tblStatutes.Effective_Date] Between #" & Me.txtDate1 & "# And #" & Me.txtDate2 & "#"
strWhere1 = "[Last_Reviewed_Date] Between #" & Me.txtDate1 & "# And #" & Me.txtDate2 & "#" & " OR " & "[Effective_Date] Between #" & Me.txtDate1 & "# And #" & Me.txtDate2 & "#"
' strWhere1 = "tblStatutes.Last_Reviewed_Date Between #" & Format(Me!txtDate1, "yyyy-mm-dd") & "# And #" & Format(Me!txtDate2, "yyyy-mm-dd") & "#"
End If
'Debug.Print strWhere1
'Combo 1
If IsNull(Me.cboType) Then
strWhere1 = strWhere1
Else
If strWhere1 = "" Then
strWhere1 = "[tblStatutes].[Type] = '" & Me.cboType & "'"
Else
strWhere1 = strWhere1 & " AND [tblStatutes].[Type] = '" & Me.cboType & "'"
End If
End If
'Debug.Print strWhere1
'Combo 2
If IsNull(Me.cboFunction) Then
strWhere1 = strWhere1
Else
If strWhere1 = "" Then
strWhere1 = "[tblStatutes].[Function_Type] = '" & Me.cboFunction & "'"
Else
strWhere1 = strWhere1 & " AND [tblStatutes].[Function_Type] = '" & Me.cboFunction & "'"
End If
End If
'Combo 3
If IsNull(Me.cboExemption_Status) Then
strWhere1 = strWhere1
Else
If strWhere1 = "" Then
strWhere1 = "[tblStatutes].[Exemption_Status] = '" & Me.cboExemption_Status & "'"
Else
strWhere1 = strWhere1 & " AND [tblStatutes].[Exemption_Status] = '" & Me.cboExemption_Status & "'"
End If
End If
'Debug.Print strWhere1
On Error Resume Next
DoCmd.OpenReport strReportName, acViewPreview, , strWhere1
Me.txtDate1 = Null
Me.txtDate2 = Null
Me.cboType = Null
Me.cboFunction = Null
Me.cboExemption_Status = Null
End Sub
Thanks,
Rita