parameters using docmd.openreport

S

seeker

The following code is executed when a button on a form is clicked;

DoCmd.OpenReport "rptOutreachDoneMemberSelect", acViewPreview, , "[Last
Name] = '" & LastName.Value & "' and [First Name] = '" & FirstName.Value & "'"

[Last Name] and [First Name] are parameters in the query that the report is
based. I want data passed to those parameters when the report is opened by
the button. I also have these parameters in the title of the report so they
are needed in the query. I want the report to run without the parameter
asking for data.
 
S

seeker

from textboxes in the same form that the button to execute the report is
found thus lastname.value and firstname.value

Klatuu said:
Where do you initially get the parameter values?


--
Dave Hargis, Microsoft Access MVP


seeker said:
The following code is executed when a button on a form is clicked;

DoCmd.OpenReport "rptOutreachDoneMemberSelect", acViewPreview, , "[Last
Name] = '" & LastName.Value & "' and [First Name] = '" & FirstName.Value & "'"

[Last Name] and [First Name] are parameters in the query that the report is
based. I want data passed to those parameters when the report is opened by
the button. I also have these parameters in the title of the report so they
are needed in the query. I want the report to run without the parameter
asking for data.
 
K

Klatuu

I am not quite sure why you are not getting the parameters. The only thing I
see is that you don't need to use the Value property (it is the default) and
you should always qualify you control names with the form reference. I would
write it as:

DoCmd.OpenReport "rptOutreachDoneMemberSelect", acViewPreview, , "[Last
Name] = """ & Me.LastName & """ and [First Name] = """ & Me.FirstName & """"

--
Dave Hargis, Microsoft Access MVP


seeker said:
from textboxes in the same form that the button to execute the report is
found thus lastname.value and firstname.value

Klatuu said:
Where do you initially get the parameter values?


--
Dave Hargis, Microsoft Access MVP


seeker said:
The following code is executed when a button on a form is clicked;

DoCmd.OpenReport "rptOutreachDoneMemberSelect", acViewPreview, , "[Last
Name] = '" & LastName.Value & "' and [First Name] = '" & FirstName.Value & "'"

[Last Name] and [First Name] are parameters in the query that the report is
based. I want data passed to those parameters when the report is opened by
the button. I also have these parameters in the title of the report so they
are needed in the query. I want the report to run without the parameter
asking for data.
 
S

seeker

Thank you for your reply. After initiating your suggestion, when I execute
the button to run the report it is still asking for [Last Name] and [First
Name].

Klatuu said:
I am not quite sure why you are not getting the parameters. The only thing I
see is that you don't need to use the Value property (it is the default) and
you should always qualify you control names with the form reference. I would
write it as:

DoCmd.OpenReport "rptOutreachDoneMemberSelect", acViewPreview, , "[Last
Name] = """ & Me.LastName & """ and [First Name] = """ & Me.FirstName & """"

--
Dave Hargis, Microsoft Access MVP


seeker said:
from textboxes in the same form that the button to execute the report is
found thus lastname.value and firstname.value

Klatuu said:
Where do you initially get the parameter values?


--
Dave Hargis, Microsoft Access MVP


:

The following code is executed when a button on a form is clicked;

DoCmd.OpenReport "rptOutreachDoneMemberSelect", acViewPreview, , "[Last
Name] = '" & LastName.Value & "' and [First Name] = '" & FirstName.Value & "'"

[Last Name] and [First Name] are parameters in the query that the report is
based. I want data passed to those parameters when the report is opened by
the button. I also have these parameters in the title of the report so they
are needed in the query. I want the report to run without the parameter
asking for data.
 
K

Klatuu

I think it just dawned on me what the problem is. It sounds like you have
those parameters identifed in the report's recordset query. Take them out.
When using the Where argument of the OpenReport method, you don't put the
parameters in the query.
--
Dave Hargis, Microsoft Access MVP


seeker said:
Thank you for your reply. After initiating your suggestion, when I execute
the button to run the report it is still asking for [Last Name] and [First
Name].

Klatuu said:
I am not quite sure why you are not getting the parameters. The only thing I
see is that you don't need to use the Value property (it is the default) and
you should always qualify you control names with the form reference. I would
write it as:

DoCmd.OpenReport "rptOutreachDoneMemberSelect", acViewPreview, , "[Last
Name] = """ & Me.LastName & """ and [First Name] = """ & Me.FirstName & """"

--
Dave Hargis, Microsoft Access MVP


seeker said:
from textboxes in the same form that the button to execute the report is
found thus lastname.value and firstname.value

:

Where do you initially get the parameter values?


--
Dave Hargis, Microsoft Access MVP


:

The following code is executed when a button on a form is clicked;

DoCmd.OpenReport "rptOutreachDoneMemberSelect", acViewPreview, , "[Last
Name] = '" & LastName.Value & "' and [First Name] = '" & FirstName.Value & "'"

[Last Name] and [First Name] are parameters in the query that the report is
based. I want data passed to those parameters when the report is opened by
the button. I also have these parameters in the title of the report so they
are needed in the query. I want the report to run without the parameter
asking for data.
 
S

seeker

Thanks worked beautifully. I changed the parameters in the title to lastname
and firstname which are fields in the query and it works beautifully.

Klatuu said:
I think it just dawned on me what the problem is. It sounds like you have
those parameters identifed in the report's recordset query. Take them out.
When using the Where argument of the OpenReport method, you don't put the
parameters in the query.
--
Dave Hargis, Microsoft Access MVP


seeker said:
Thank you for your reply. After initiating your suggestion, when I execute
the button to run the report it is still asking for [Last Name] and [First
Name].

Klatuu said:
I am not quite sure why you are not getting the parameters. The only thing I
see is that you don't need to use the Value property (it is the default) and
you should always qualify you control names with the form reference. I would
write it as:

DoCmd.OpenReport "rptOutreachDoneMemberSelect", acViewPreview, , "[Last
Name] = """ & Me.LastName & """ and [First Name] = """ & Me.FirstName & """"

--
Dave Hargis, Microsoft Access MVP


:

from textboxes in the same form that the button to execute the report is
found thus lastname.value and firstname.value

:

Where do you initially get the parameter values?


--
Dave Hargis, Microsoft Access MVP


:

The following code is executed when a button on a form is clicked;

DoCmd.OpenReport "rptOutreachDoneMemberSelect", acViewPreview, , "[Last
Name] = '" & LastName.Value & "' and [First Name] = '" & FirstName.Value & "'"

[Last Name] and [First Name] are parameters in the query that the report is
based. I want data passed to those parameters when the report is opened by
the button. I also have these parameters in the title of the report so they
are needed in the query. I want the report to run without the parameter
asking for data.
 
S

sabo

Thanks worked beautifully.  I changed the parameters in the title to lastname
and firstname which are fields in the query and it works beautifully.



Klatuu said:
I think it just dawned on me what the problem is.  It sounds like youhave
those parameters identifed in the report's recordset query.  Take them out.  
When using the Where argument of the OpenReport method, you don't put the
parameters in the query.
Thank you for your reply.  After initiating your suggestion, when Iexecute
the button to run the report it is still asking for [Last Name] and [First
Name].
:
I am not quite sure why you are not getting the parameters.  The only thing I
see is that you don't need to use the Value property (it is the default) and
you should always qualify you control names with the form reference..  I would
write it as:
  DoCmd.OpenReport "rptOutreachDoneMemberSelect", acViewPreview, , "[Last
Name] = """ & Me.LastName & """ and [First Name] = """ & Me.FirstName & """"
--
Dave Hargis, Microsoft Access MVP
:
from textboxes in the same form that the button to execute the report is
found thus lastname.value and firstname.value
:
Where do you initially get the parameter values?
--
Dave Hargis, Microsoft Access MVP
:
The following code is executed when a button on a form is clicked;
  DoCmd.OpenReport "rptOutreachDoneMemberSelect", acViewPreview, , "[Last
Name] = '" & LastName.Value & "' and [First Name] = '" & FirstName.Value & "'"
[Last Name] and [First Name] are parameters in the query thatthe report is
based.  I want data passed to those parameters when the report is opened by
the button.  I also have these parameters in the title of the report so they
are needed in the query.  I want the report to run without the parameter
asking for data.- Hide quoted text -

- Show quoted text -

Hi,
I have the same problem but I didn't understand what you meen to take
the parameters out.
Thank for explain that, Sara
 

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