vendredi 17 novembre 2017

MS Access VBA Ranged Dates with BETWEEN or single entry with in Text Boxes

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.

Anything helps.

Aucun commentaire:

Enregistrer un commentaire