I'm looking for some assistance on this Look up code I managed to put together.
If Me.txtStartDate > "" And Me.txtEndDate > "" Then
varWhere = varWhere & "[CompletionDate] BETWEEN #" & Me.txtStartDate & "# AND #" & Me.txtEndDate & "#"
ElseIf Me.txtStartDate > "" And Me.txtEndDate Is Nothing Then
varWhere = varWhere & "[CompletionDate] = """" & Me.txtStartDate & " * "" And ""
ElseIf Me.txtStartDate Is Nothing And Me.txtEndDate > "" Then
MsgBox "Please Input a Start Date", vbOKOnly, Error
End If
I feel like the code itself is self explanatory of my goals. However I'm wanting to allow the user to input into Me.txtStartDate
& Me.txtEndDate
giving the range. Also, Allowing the user to just input into Me.txtStartDate
for a single date. I have attempted combining the two Along with a message box if they input into end date alone.
Its not working for me, I can get either or working.
My Question is "How do I combine these three statements, so they work in a conditional statement way?"
Anything helps.
I'm not sure what you're trying to do. I like to use datepickers.
Private Sub Form_Open(Cancel As Integer)
Me.DTPickerStart.DefaultValue = "Date()"
Me.DTPickerEnd.DefaultValue = "Date()"
Then I'd do something like this.
If (Nz(Me.Me.txtStartDate.Value) = "") Then
MsgBox "Please select a Start Date.", vbCritical + vbOKOnly, "Error"
ElseIf (Nz(Me.txtEndDate.Value) = "") Then
MsgBox "Please select a End Date.", vbCritical + vbOKOnly, "Error"
Else
DoCmd.OpenReport "XYZRpt", acViewPreview
Or you could do..
DoCmd.OpenQuery "Passthroughquery" that links to an SQL procedure. I'm not
sure what you're trying to do though.
End If
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.