krasniusha
New member
- Local time
- Today, 00:30
- Joined
- Jun 1, 2014
- Messages
- 4
I have a table with only two fields and one record: BegDate and EndDate (beginning and end date of the reporting period respectively). I also made a function with variables that look up those values for use as a date parameter in a query.
I am a VBA novice, and need a help with the syntax.
Here is the code:
Option Compare Database
Option Explicit
Public Function getCurrentRepDates() As Date
Dim dtBegDate As Date
dtBegDate = DLookup("BegDate", "tblCurrentRepDates")
Dim dtEndDate As Date
dtEndDate = DLookup("EndDate", "tblCurrentRepDates")
Dim dtCurrentRepDates As Date
dtCurrentRepDates = Between dtBegDate And dtEndDate
getCurrentRepDates = gdtCurrentRepDates
End Function
I am getting a syntax error for the line marked red. How can I use "Between" function in VBA code?
Appreciate your help!
I am a VBA novice, and need a help with the syntax.
Here is the code:
Option Compare Database
Option Explicit
Public Function getCurrentRepDates() As Date
Dim dtBegDate As Date
dtBegDate = DLookup("BegDate", "tblCurrentRepDates")
Dim dtEndDate As Date
dtEndDate = DLookup("EndDate", "tblCurrentRepDates")
Dim dtCurrentRepDates As Date
dtCurrentRepDates = Between dtBegDate And dtEndDate
getCurrentRepDates = gdtCurrentRepDates
End Function
I am getting a syntax error for the line marked red. How can I use "Between" function in VBA code?
Appreciate your help!