Date Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to run the following code from an event procedure under the time
from the switchboard to auto print report. It's not picking up the values of
my start date field. Any suggestions or is this a better way to do this?


Dim stDocName As String
Dim stStartDate As String
Dim stDocDate As String
Dim stPrintDate As String

stDocName = "Page1"
stStartDate = "[start-date]"
stDocDate = (Now) - 1
stPrintDate = stStartDate = stDocDate

DoCmd.OpenReport stDocName, acNormal, , stPrintDate
 
Ken,

I tried that originally and got the following message

Microsoft Access can't find the fild '|' referred to in your expression

I also tried

stStartDate = ([start-date])

I'm about ready to throw in the towel

Ken Snell said:
Change
stStartDate = "[start-date]"

to
stStartDate = [start-date]


--

Ken Snell
<MS ACCESS MVP>



Sash said:
I'm trying to run the following code from an event procedure under the time
from the switchboard to auto print report. It's not picking up the values of
my start date field. Any suggestions or is this a better way to do this?


Dim stDocName As String
Dim stStartDate As String
Dim stDocDate As String
Dim stPrintDate As String

stDocName = "Page1"
stStartDate = "[start-date]"
stDocDate = (Now) - 1
stPrintDate = stStartDate = stDocDate

DoCmd.OpenReport stDocName, acNormal, , stPrintDate
 
What is this line of code supposed to be doing?
stPrintDate = stStartDate = stDocDate

Is this supposed to be the filtering criterion string for your report? If
yes, then I think your code has a few changes to be made:

Dim stDocName As String
Dim stPrintDate As String
stDocName = "Page1"
stPrintDate = "[start-date]=#" & Format(Date() - 1, "m/d/yyyy") & "#"
DoCmd.OpenReport stDocName, acNormal, , stPrintDate


--

Ken Snell
<MS ACCESS MVP>

Sash said:
Ken,

I tried that originally and got the following message

Microsoft Access can't find the fild '|' referred to in your expression

I also tried

stStartDate = ([start-date])

I'm about ready to throw in the towel

Ken Snell said:
Change
stStartDate = "[start-date]"

to
stStartDate = [start-date]


--

Ken Snell
<MS ACCESS MVP>



Sash said:
I'm trying to run the following code from an event procedure under the time
from the switchboard to auto print report. It's not picking up the
values
of
my start date field. Any suggestions or is this a better way to do this?


Dim stDocName As String
Dim stStartDate As String
Dim stDocDate As String
Dim stPrintDate As String

stDocName = "Page1"
stStartDate = "[start-date]"
stDocDate = (Now) - 1
stPrintDate = stStartDate = stDocDate

DoCmd.OpenReport stDocName, acNormal, , stPrintDate
 
Thanks Ken. Exactly what I needed.

Ken Snell said:
What is this line of code supposed to be doing?
stPrintDate = stStartDate = stDocDate

Is this supposed to be the filtering criterion string for your report? If
yes, then I think your code has a few changes to be made:

Dim stDocName As String
Dim stPrintDate As String
stDocName = "Page1"
stPrintDate = "[start-date]=#" & Format(Date() - 1, "m/d/yyyy") & "#"
DoCmd.OpenReport stDocName, acNormal, , stPrintDate


--

Ken Snell
<MS ACCESS MVP>

Sash said:
Ken,

I tried that originally and got the following message

Microsoft Access can't find the fild '|' referred to in your expression

I also tried

stStartDate = ([start-date])

I'm about ready to throw in the towel

Ken Snell said:
Change
stStartDate = "[start-date]"

to
stStartDate = [start-date]


--

Ken Snell
<MS ACCESS MVP>



I'm trying to run the following code from an event procedure under the
time
from the switchboard to auto print report. It's not picking up the values
of
my start date field. Any suggestions or is this a better way to do this?


Dim stDocName As String
Dim stStartDate As String
Dim stDocDate As String
Dim stPrintDate As String

stDocName = "Page1"
stStartDate = "[start-date]"
stDocDate = (Now) - 1
stPrintDate = stStartDate = stDocDate

DoCmd.OpenReport stDocName, acNormal, , stPrintDate
 
Back
Top