Microsoft Access cannot find the field "|" referred to in your exp

G

Guest

well, the subject heading truncated the word 'expression' but you get the
idea...

i'm using a2k and i want to print a report which is contrained to just those
records having FollowUp dates the user specifies in two unbound l/u controls
on a form.

one of the buttons on the form is intended to give the user just a preview
of the report.

Private Sub TrackDM_Click()
On Error GoTo Err_TrackDM_Click

Dim stDocName As String

stDocName = "By DM: Patients on Follow-Up"
DoCmd.OpenReport stDocName, acViewPreview, [Date_on_List] & Between &
"#" & Forms![Tracking Print By DM]![StartDate] & "# And #" & Forms![Tracking
Print By DM]![StopDate] & "#"

Exit_TrackDM_Click:
Exit Sub

Err_TrackDM_Click:
MsgBox Err.description
Resume Exit_TrackDM_Click

End Sub

and this code seems to be giving a2k heartburn for some reason. the VBA
compiles alright but ends up landing in the error field (given). does anyone
have any light to shed on this thread?
 
D

Duane Hookom

Try this code:

Private Sub TrackDM_Click()
On Error GoTo Err_TrackDM_Click

Dim stDocName As String
Dim strWhere as String

stDocName = "By DM: Patients on Follow-Up"
strWhere = "[Date_on_List] Between #" & _
Forms![Tracking Print By DM]![StartDate] & _
"# And #" & Forms![Tracking Print By DM]![StopDate] & "#"

DoCmd.OpenReport stDocName, acViewPreview, , strWhere

Exit_TrackDM_Click:
Exit Sub

Err_TrackDM_Click:
MsgBox Err.description
Resume Exit_TrackDM_Click

End Sub
 
G

Guest

thanks a heap duane :) works swell....but just one thing: 'why'? i think i
see what you have done (parsing the code into another variable) but why would
that have the desired effect?

looking at a gift horse in the mouth,

-ted


Duane Hookom said:
Try this code:

Private Sub TrackDM_Click()
On Error GoTo Err_TrackDM_Click

Dim stDocName As String
Dim strWhere as String

stDocName = "By DM: Patients on Follow-Up"
strWhere = "[Date_on_List] Between #" & _
Forms![Tracking Print By DM]![StartDate] & _
"# And #" & Forms![Tracking Print By DM]![StopDate] & "#"

DoCmd.OpenReport stDocName, acViewPreview, , strWhere

Exit_TrackDM_Click:
Exit Sub

Err_TrackDM_Click:
MsgBox Err.description
Resume Exit_TrackDM_Click

End Sub


--
Duane Hookom
MS Access MVP
--

Ted said:
well, the subject heading truncated the word 'expression' but you get the
idea...

i'm using a2k and i want to print a report which is contrained to just
those
records having FollowUp dates the user specifies in two unbound l/u
controls
on a form.

one of the buttons on the form is intended to give the user just a preview
of the report.

Private Sub TrackDM_Click()
On Error GoTo Err_TrackDM_Click

Dim stDocName As String

stDocName = "By DM: Patients on Follow-Up"
DoCmd.OpenReport stDocName, acViewPreview, [Date_on_List] & Between &
"#" & Forms![Tracking Print By DM]![StartDate] & "# And #" &
Forms![Tracking
Print By DM]![StopDate] & "#"

Exit_TrackDM_Click:
Exit Sub

Err_TrackDM_Click:
MsgBox Err.description
Resume Exit_TrackDM_Click

End Sub

and this code seems to be giving a2k heartburn for some reason. the VBA
compiles alright but ends up landing in the error field (given). does
anyone
have any light to shed on this thread?
 
D

Duane Hookom

I made two other changes:
1) set the strWhere after another comma in the OpenReport method
2) wrapped the literal stuff inside quotes
Yours:
[Date_on_List] & Between & "#" &
Mine:
"[Date_on_List] Between #" &

--
Duane Hookom
MS Access MVP
--

Ted said:
thanks a heap duane :) works swell....but just one thing: 'why'? i think
i
see what you have done (parsing the code into another variable) but why
would
that have the desired effect?

looking at a gift horse in the mouth,

-ted


Duane Hookom said:
Try this code:

Private Sub TrackDM_Click()
On Error GoTo Err_TrackDM_Click

Dim stDocName As String
Dim strWhere as String

stDocName = "By DM: Patients on Follow-Up"
strWhere = "[Date_on_List] Between #" & _
Forms![Tracking Print By DM]![StartDate] & _
"# And #" & Forms![Tracking Print By DM]![StopDate] & "#"

DoCmd.OpenReport stDocName, acViewPreview, , strWhere

Exit_TrackDM_Click:
Exit Sub

Err_TrackDM_Click:
MsgBox Err.description
Resume Exit_TrackDM_Click

End Sub


--
Duane Hookom
MS Access MVP
--

Ted said:
well, the subject heading truncated the word 'expression' but you get
the
idea...

i'm using a2k and i want to print a report which is contrained to just
those
records having FollowUp dates the user specifies in two unbound l/u
controls
on a form.

one of the buttons on the form is intended to give the user just a
preview
of the report.

Private Sub TrackDM_Click()
On Error GoTo Err_TrackDM_Click

Dim stDocName As String

stDocName = "By DM: Patients on Follow-Up"
DoCmd.OpenReport stDocName, acViewPreview, [Date_on_List] & Between
&
"#" & Forms![Tracking Print By DM]![StartDate] & "# And #" &
Forms![Tracking
Print By DM]![StopDate] & "#"

Exit_TrackDM_Click:
Exit Sub

Err_TrackDM_Click:
MsgBox Err.description
Resume Exit_TrackDM_Click

End Sub

and this code seems to be giving a2k heartburn for some reason. the VBA
compiles alright but ends up landing in the error field (given). does
anyone
have any light to shed on this thread?
 
G

Guest

forgive my lack of unfamiliarity with what you're saying, but (and thanks for
pointing out what my ageing eyes did not pick up on) the difference in #2 has
what significance? since mine did not fail to compile, i assumed that the
pairing of all the quotation marks must've satisfied the language deities in
the vba volcano and that all was copacetic.

Duane Hookom said:
I made two other changes:
1) set the strWhere after another comma in the OpenReport method
2) wrapped the literal stuff inside quotes
Yours:
[Date_on_List] & Between & "#" &
Mine:
"[Date_on_List] Between #" &

--
Duane Hookom
MS Access MVP
--

Ted said:
thanks a heap duane :) works swell....but just one thing: 'why'? i think
i
see what you have done (parsing the code into another variable) but why
would
that have the desired effect?

looking at a gift horse in the mouth,

-ted


Duane Hookom said:
Try this code:

Private Sub TrackDM_Click()
On Error GoTo Err_TrackDM_Click

Dim stDocName As String
Dim strWhere as String

stDocName = "By DM: Patients on Follow-Up"
strWhere = "[Date_on_List] Between #" & _
Forms![Tracking Print By DM]![StartDate] & _
"# And #" & Forms![Tracking Print By DM]![StopDate] & "#"

DoCmd.OpenReport stDocName, acViewPreview, , strWhere

Exit_TrackDM_Click:
Exit Sub

Err_TrackDM_Click:
MsgBox Err.description
Resume Exit_TrackDM_Click

End Sub


--
Duane Hookom
MS Access MVP
--

well, the subject heading truncated the word 'expression' but you get
the
idea...

i'm using a2k and i want to print a report which is contrained to just
those
records having FollowUp dates the user specifies in two unbound l/u
controls
on a form.

one of the buttons on the form is intended to give the user just a
preview
of the report.

Private Sub TrackDM_Click()
On Error GoTo Err_TrackDM_Click

Dim stDocName As String

stDocName = "By DM: Patients on Follow-Up"
DoCmd.OpenReport stDocName, acViewPreview, [Date_on_List] & Between
&
"#" & Forms![Tracking Print By DM]![StartDate] & "# And #" &
Forms![Tracking
Print By DM]![StopDate] & "#"

Exit_TrackDM_Click:
Exit Sub

Err_TrackDM_Click:
MsgBox Err.description
Resume Exit_TrackDM_Click

End Sub

and this code seems to be giving a2k heartburn for some reason. the VBA
compiles alright but ends up landing in the error field (given). does
anyone
have any light to shed on this thread?
 
D

Duane Hookom

The where clause expects a string variable or expression. Your code should
not have compiled unless you had a variable named "Between".

Do you have
Option Explicit
in all of your module general declarations?

--
Duane Hookom
MS Access MVP
--

Ted said:
forgive my lack of unfamiliarity with what you're saying, but (and thanks
for
pointing out what my ageing eyes did not pick up on) the difference in #2
has
what significance? since mine did not fail to compile, i assumed that the
pairing of all the quotation marks must've satisfied the language deities
in
the vba volcano and that all was copacetic.

Duane Hookom said:
I made two other changes:
1) set the strWhere after another comma in the OpenReport method
2) wrapped the literal stuff inside quotes
Yours:
[Date_on_List] & Between & "#" &
Mine:
"[Date_on_List] Between #" &

--
Duane Hookom
MS Access MVP
--

Ted said:
thanks a heap duane :) works swell....but just one thing: 'why'? i
think
i
see what you have done (parsing the code into another variable) but why
would
that have the desired effect?

looking at a gift horse in the mouth,

-ted


:

Try this code:

Private Sub TrackDM_Click()
On Error GoTo Err_TrackDM_Click

Dim stDocName As String
Dim strWhere as String

stDocName = "By DM: Patients on Follow-Up"
strWhere = "[Date_on_List] Between #" & _
Forms![Tracking Print By DM]![StartDate] & _
"# And #" & Forms![Tracking Print By DM]![StopDate] & "#"

DoCmd.OpenReport stDocName, acViewPreview, , strWhere

Exit_TrackDM_Click:
Exit Sub

Err_TrackDM_Click:
MsgBox Err.description
Resume Exit_TrackDM_Click

End Sub


--
Duane Hookom
MS Access MVP
--

well, the subject heading truncated the word 'expression' but you
get
the
idea...

i'm using a2k and i want to print a report which is contrained to
just
those
records having FollowUp dates the user specifies in two unbound l/u
controls
on a form.

one of the buttons on the form is intended to give the user just a
preview
of the report.

Private Sub TrackDM_Click()
On Error GoTo Err_TrackDM_Click

Dim stDocName As String

stDocName = "By DM: Patients on Follow-Up"
DoCmd.OpenReport stDocName, acViewPreview, [Date_on_List] &
Between
&
"#" & Forms![Tracking Print By DM]![StartDate] & "# And #" &
Forms![Tracking
Print By DM]![StopDate] & "#"

Exit_TrackDM_Click:
Exit Sub

Err_TrackDM_Click:
MsgBox Err.description
Resume Exit_TrackDM_Click

End Sub

and this code seems to be giving a2k heartburn for some reason. the
VBA
compiles alright but ends up landing in the error field (given).
does
anyone
have any light to shed on this thread?
 
G

Guest

i do now duane, thanks! i think there's an option somewhere in all this to
automatically propagate that "option explicit" feature in vba as well, but
where?


Duane Hookom said:
The where clause expects a string variable or expression. Your code should
not have compiled unless you had a variable named "Between".

Do you have
Option Explicit
in all of your module general declarations?

--
Duane Hookom
MS Access MVP
--

Ted said:
forgive my lack of unfamiliarity with what you're saying, but (and thanks
for
pointing out what my ageing eyes did not pick up on) the difference in #2
has
what significance? since mine did not fail to compile, i assumed that the
pairing of all the quotation marks must've satisfied the language deities
in
the vba volcano and that all was copacetic.

Duane Hookom said:
I made two other changes:
1) set the strWhere after another comma in the OpenReport method
2) wrapped the literal stuff inside quotes
Yours:
[Date_on_List] & Between & "#" &
Mine:
"[Date_on_List] Between #" &

--
Duane Hookom
MS Access MVP
--

thanks a heap duane :) works swell....but just one thing: 'why'? i
think
i
see what you have done (parsing the code into another variable) but why
would
that have the desired effect?

looking at a gift horse in the mouth,

-ted


:

Try this code:

Private Sub TrackDM_Click()
On Error GoTo Err_TrackDM_Click

Dim stDocName As String
Dim strWhere as String

stDocName = "By DM: Patients on Follow-Up"
strWhere = "[Date_on_List] Between #" & _
Forms![Tracking Print By DM]![StartDate] & _
"# And #" & Forms![Tracking Print By DM]![StopDate] & "#"

DoCmd.OpenReport stDocName, acViewPreview, , strWhere

Exit_TrackDM_Click:
Exit Sub

Err_TrackDM_Click:
MsgBox Err.description
Resume Exit_TrackDM_Click

End Sub


--
Duane Hookom
MS Access MVP
--

well, the subject heading truncated the word 'expression' but you
get
the
idea...

i'm using a2k and i want to print a report which is contrained to
just
those
records having FollowUp dates the user specifies in two unbound l/u
controls
on a form.

one of the buttons on the form is intended to give the user just a
preview
of the report.

Private Sub TrackDM_Click()
On Error GoTo Err_TrackDM_Click

Dim stDocName As String

stDocName = "By DM: Patients on Follow-Up"
DoCmd.OpenReport stDocName, acViewPreview, [Date_on_List] &
Between
&
"#" & Forms![Tracking Print By DM]![StartDate] & "# And #" &
Forms![Tracking
Print By DM]![StopDate] & "#"

Exit_TrackDM_Click:
Exit Sub

Err_TrackDM_Click:
MsgBox Err.description
Resume Exit_TrackDM_Click

End Sub

and this code seems to be giving a2k heartburn for some reason. the
VBA
compiles alright but ends up landing in the error field (given).
does
anyone
have any light to shed on this thread?
 
D

Duane Hookom

Check Tools->Options while in a code window.

--
Duane Hookom
MS Access MVP
--

Ted said:
i do now duane, thanks! i think there's an option somewhere in all this to
automatically propagate that "option explicit" feature in vba as well, but
where?


Duane Hookom said:
The where clause expects a string variable or expression. Your code
should
not have compiled unless you had a variable named "Between".

Do you have
Option Explicit
in all of your module general declarations?

--
Duane Hookom
MS Access MVP
--

Ted said:
forgive my lack of unfamiliarity with what you're saying, but (and
thanks
for
pointing out what my ageing eyes did not pick up on) the difference in
#2
has
what significance? since mine did not fail to compile, i assumed that
the
pairing of all the quotation marks must've satisfied the language
deities
in
the vba volcano and that all was copacetic.

:

I made two other changes:
1) set the strWhere after another comma in the OpenReport method
2) wrapped the literal stuff inside quotes
Yours:
[Date_on_List] & Between & "#" &
Mine:
"[Date_on_List] Between #" &

--
Duane Hookom
MS Access MVP
--

thanks a heap duane :) works swell....but just one thing: 'why'? i
think
i
see what you have done (parsing the code into another variable) but
why
would
that have the desired effect?

looking at a gift horse in the mouth,

-ted


:

Try this code:

Private Sub TrackDM_Click()
On Error GoTo Err_TrackDM_Click

Dim stDocName As String
Dim strWhere as String

stDocName = "By DM: Patients on Follow-Up"
strWhere = "[Date_on_List] Between #" & _
Forms![Tracking Print By DM]![StartDate] & _
"# And #" & Forms![Tracking Print By DM]![StopDate] & "#"

DoCmd.OpenReport stDocName, acViewPreview, , strWhere

Exit_TrackDM_Click:
Exit Sub

Err_TrackDM_Click:
MsgBox Err.description
Resume Exit_TrackDM_Click

End Sub


--
Duane Hookom
MS Access MVP
--

well, the subject heading truncated the word 'expression' but you
get
the
idea...

i'm using a2k and i want to print a report which is contrained to
just
those
records having FollowUp dates the user specifies in two unbound
l/u
controls
on a form.

one of the buttons on the form is intended to give the user just
a
preview
of the report.

Private Sub TrackDM_Click()
On Error GoTo Err_TrackDM_Click

Dim stDocName As String

stDocName = "By DM: Patients on Follow-Up"
DoCmd.OpenReport stDocName, acViewPreview, [Date_on_List] &
Between
&
"#" & Forms![Tracking Print By DM]![StartDate] & "# And #" &
Forms![Tracking
Print By DM]![StopDate] & "#"

Exit_TrackDM_Click:
Exit Sub

Err_TrackDM_Click:
MsgBox Err.description
Resume Exit_TrackDM_Click

End Sub

and this code seems to be giving a2k heartburn for some reason.
the
VBA
compiles alright but ends up landing in the error field (given).
does
anyone
have any light to shed on this thread?
 
G

Guest

cool, thx.

Duane Hookom said:
Check Tools->Options while in a code window.

--
Duane Hookom
MS Access MVP
--

Ted said:
i do now duane, thanks! i think there's an option somewhere in all this to
automatically propagate that "option explicit" feature in vba as well, but
where?


Duane Hookom said:
The where clause expects a string variable or expression. Your code
should
not have compiled unless you had a variable named "Between".

Do you have
Option Explicit
in all of your module general declarations?

--
Duane Hookom
MS Access MVP
--

forgive my lack of unfamiliarity with what you're saying, but (and
thanks
for
pointing out what my ageing eyes did not pick up on) the difference in
#2
has
what significance? since mine did not fail to compile, i assumed that
the
pairing of all the quotation marks must've satisfied the language
deities
in
the vba volcano and that all was copacetic.

:

I made two other changes:
1) set the strWhere after another comma in the OpenReport method
2) wrapped the literal stuff inside quotes
Yours:
[Date_on_List] & Between & "#" &
Mine:
"[Date_on_List] Between #" &

--
Duane Hookom
MS Access MVP
--

thanks a heap duane :) works swell....but just one thing: 'why'? i
think
i
see what you have done (parsing the code into another variable) but
why
would
that have the desired effect?

looking at a gift horse in the mouth,

-ted


:

Try this code:

Private Sub TrackDM_Click()
On Error GoTo Err_TrackDM_Click

Dim stDocName As String
Dim strWhere as String

stDocName = "By DM: Patients on Follow-Up"
strWhere = "[Date_on_List] Between #" & _
Forms![Tracking Print By DM]![StartDate] & _
"# And #" & Forms![Tracking Print By DM]![StopDate] & "#"

DoCmd.OpenReport stDocName, acViewPreview, , strWhere

Exit_TrackDM_Click:
Exit Sub

Err_TrackDM_Click:
MsgBox Err.description
Resume Exit_TrackDM_Click

End Sub


--
Duane Hookom
MS Access MVP
--

well, the subject heading truncated the word 'expression' but you
get
the
idea...

i'm using a2k and i want to print a report which is contrained to
just
those
records having FollowUp dates the user specifies in two unbound
l/u
controls
on a form.

one of the buttons on the form is intended to give the user just
a
preview
of the report.

Private Sub TrackDM_Click()
On Error GoTo Err_TrackDM_Click

Dim stDocName As String

stDocName = "By DM: Patients on Follow-Up"
DoCmd.OpenReport stDocName, acViewPreview, [Date_on_List] &
Between
&
"#" & Forms![Tracking Print By DM]![StartDate] & "# And #" &
Forms![Tracking
Print By DM]![StopDate] & "#"

Exit_TrackDM_Click:
Exit Sub

Err_TrackDM_Click:
MsgBox Err.description
Resume Exit_TrackDM_Click

End Sub

and this code seems to be giving a2k heartburn for some reason.
the
VBA
compiles alright but ends up landing in the error field (given).
does
anyone
have any light to shed on this thread?
 

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