Open Report Argument method

G

Guest

Access2003;
am humbled and had to use a macro to open a report to a specific record...
in the Where clause of the OpenReport macro I put:
[ReportField]=Forms![Form1].[FormControl1]

everything works fine.......

but went around in circles attempting to do this via the OpenReport argument
and would greatly appreciate some patient guidance. Thought this should work:

Dim strCriteria As String
strCriteria = "[ReportField] = &[Me.FormControl1]&"

DoCmd.OpenReport "NameOfReport", acViewPreview, , strCriteria

I think I did every conceivable combination of " ' in surrounding the
variable FormControl1 (which is a text field) but to no avail...
 
R

Rob Parker

Try:
strCriteria = "[ReportField] = '" & [Me.FormControl1] & "'"

Exaggerated for clarity, that's
strCriteria = "[ReportField] = ' " & [Me.FormControl1] & " ' "


HTH,

Rob
 
R

Rick Brandt

NetworkTrade said:
Access2003;
am humbled and had to use a macro to open a report to a specific
record...
in the Where clause of the OpenReport macro I put:
[ReportField]=Forms![Form1].[FormControl1]

everything works fine.......

but went around in circles attempting to do this via the OpenReport
argument and would greatly appreciate some patient guidance. Thought
this should work:

Dim strCriteria As String
strCriteria = "[ReportField] = &[Me.FormControl1]&"

DoCmd.OpenReport "NameOfReport", acViewPreview, , strCriteria

I think I did every conceivable combination of " ' in surrounding the
variable FormControl1 (which is a text field) but to no avail...


strCriteria = "[ReportField] = '" & Me.FormControl1 & "'"

For clarity only...

strCriteria = "[ReportField] = ' " & Me.FormControl1 & " ' "
 
G

Guest

runtime error 2465
Access can not find the field "I" referred to in your expression

now I understand it seems that I have misnamed the control or a typo or
something but after triple checking am left confused.....

possibly the problem is not the syntax but the recognition of the
field....but not sure
--
NTC


Rob Parker said:
Try:
strCriteria = "[ReportField] = '" & [Me.FormControl1] & "'"

Exaggerated for clarity, that's
strCriteria = "[ReportField] = ' " & [Me.FormControl1] & " ' "


HTH,

Rob


NetworkTrade said:
Access2003;
am humbled and had to use a macro to open a report to a specific record...
in the Where clause of the OpenReport macro I put:
[ReportField]=Forms![Form1].[FormControl1]

everything works fine.......

but went around in circles attempting to do this via the OpenReport
argument
and would greatly appreciate some patient guidance. Thought this should
work:

Dim strCriteria As String
strCriteria = "[ReportField] = &[Me.FormControl1]&"

DoCmd.OpenReport "NameOfReport", acViewPreview, , strCriteria

I think I did every conceivable combination of " ' in surrounding the
variable FormControl1 (which is a text field) but to no avail...
 
G

Guest

[Report Field] has to be the name of a field in the table or query that is
the Record Source property of the report.
--
Dave Hargis, Microsoft Access MVP


NetworkTrade said:
runtime error 2465
Access can not find the field "I" referred to in your expression

now I understand it seems that I have misnamed the control or a typo or
something but after triple checking am left confused.....

possibly the problem is not the syntax but the recognition of the
field....but not sure
--
NTC


Rob Parker said:
Try:
strCriteria = "[ReportField] = '" & [Me.FormControl1] & "'"

Exaggerated for clarity, that's
strCriteria = "[ReportField] = ' " & [Me.FormControl1] & " ' "


HTH,

Rob


NetworkTrade said:
Access2003;
am humbled and had to use a macro to open a report to a specific record...
in the Where clause of the OpenReport macro I put:
[ReportField]=Forms![Form1].[FormControl1]

everything works fine.......

but went around in circles attempting to do this via the OpenReport
argument
and would greatly appreciate some patient guidance. Thought this should
work:

Dim strCriteria As String
strCriteria = "[ReportField] = &[Me.FormControl1]&"

DoCmd.OpenReport "NameOfReport", acViewPreview, , strCriteria

I think I did every conceivable combination of " ' in surrounding the
variable FormControl1 (which is a text field) but to no avail...
 
G

Guest

am fairly certain it is; am relying on the fact that it all works when opened
via the macro as my sanity check......in terms of having the correct names of
the fields involved....

I removed the variable: ' " & [Me.FormControl1] & " '

And replaced it as a trial with one valid ID: 'ABC'

And it opened the report fine/correctly to the ABC record....

remain baffled....
--
NTC


Klatuu said:
[Report Field] has to be the name of a field in the table or query that is
the Record Source property of the report.
--
Dave Hargis, Microsoft Access MVP


NetworkTrade said:
runtime error 2465
Access can not find the field "I" referred to in your expression

now I understand it seems that I have misnamed the control or a typo or
something but after triple checking am left confused.....

possibly the problem is not the syntax but the recognition of the
field....but not sure
--
NTC


Rob Parker said:
Try:
strCriteria = "[ReportField] = '" & [Me.FormControl1] & "'"

Exaggerated for clarity, that's
strCriteria = "[ReportField] = ' " & [Me.FormControl1] & " ' "


HTH,

Rob


Access2003;
am humbled and had to use a macro to open a report to a specific record...
in the Where clause of the OpenReport macro I put:
[ReportField]=Forms![Form1].[FormControl1]

everything works fine.......

but went around in circles attempting to do this via the OpenReport
argument
and would greatly appreciate some patient guidance. Thought this should
work:

Dim strCriteria As String
strCriteria = "[ReportField] = &[Me.FormControl1]&"

DoCmd.OpenReport "NameOfReport", acViewPreview, , strCriteria

I think I did every conceivable combination of " ' in surrounding the
variable FormControl1 (which is a text field) but to no avail...
 
L

Larry Linson

NetworkTrade said:
I removed the variable: ' " & [Me.FormControl1] & " '
And replaced it as a trial with one valid ID: 'ABC'
And it opened the report fine/correctly to the ABC record....
remain baffled....

Where is this code? What is the exact... copy and paste... code? Are
ReportField and FormControl1 the genuine, real names, or were you "sparing
us the confusion". If so, there may be something that is germane that we are
missing.

Put a breakpoint on the instruction after your code and examine the contents
actually calculated for strCriteria.

With the answers to the three questions above, and the (again, exact,
copied-and-pasted) content of strCriteria, someone may be able to offer a
useful suggestion.

Larry
 
G

Guest

This may be the problem:
[Me.FormControl1]

You may need to fully qualify the reference:

Forms!MyFormName!MyControlName
--
Dave Hargis, Microsoft Access MVP


NetworkTrade said:
am fairly certain it is; am relying on the fact that it all works when opened
via the macro as my sanity check......in terms of having the correct names of
the fields involved....

I removed the variable: ' " & [Me.FormControl1] & " '

And replaced it as a trial with one valid ID: 'ABC'

And it opened the report fine/correctly to the ABC record....

remain baffled....
--
NTC


Klatuu said:
[Report Field] has to be the name of a field in the table or query that is
the Record Source property of the report.
--
Dave Hargis, Microsoft Access MVP


NetworkTrade said:
runtime error 2465
Access can not find the field "I" referred to in your expression

now I understand it seems that I have misnamed the control or a typo or
something but after triple checking am left confused.....

possibly the problem is not the syntax but the recognition of the
field....but not sure
--
NTC


:

Try:
strCriteria = "[ReportField] = '" & [Me.FormControl1] & "'"

Exaggerated for clarity, that's
strCriteria = "[ReportField] = ' " & [Me.FormControl1] & " ' "


HTH,

Rob


Access2003;
am humbled and had to use a macro to open a report to a specific record...
in the Where clause of the OpenReport macro I put:
[ReportField]=Forms![Form1].[FormControl1]

everything works fine.......

but went around in circles attempting to do this via the OpenReport
argument
and would greatly appreciate some patient guidance. Thought this should
work:

Dim strCriteria As String
strCriteria = "[ReportField] = &[Me.FormControl1]&"

DoCmd.OpenReport "NameOfReport", acViewPreview, , strCriteria

I think I did every conceivable combination of " ' in surrounding the
variable FormControl1 (which is a text field) but to no avail...
 

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