Date Question

S

Sash

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
 
S

Sash

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
 
K

Ken Snell [MVP]

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
 
S

Sash

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top