I'm using Access 2003 and I'm getting a "Run-time error 13 : Type mismatch"
message from running the following code:
Private Sub Regional_AfterUpdate()
Dim Agent_Name as String
Agent_Name = "John Doe"
DoCmd.OpenReport "Clients", acViewPreview, , , Agent_Name
End Sub
Access is saying the Agent_Name variable in the OpenArgs is not the right
type. How can the OpenArgs be used to pass data to a report?
DoCmd.OpenReport "Clients", acViewPreview, , , , Agent_Name
--
Ken Snell
<MS ACCESS MVP>
"Sky Warren" <SkyW...@discussions.microsoft.com> wrote in message
news:F37E707A-1C40-4278...@microsoft.com...
Thanks, your absolutely right about that placement. I added the fourth comma
but still continued to get error messages. I read in a different thread that
OpenArgs cannot be used to pass variables to a report, only to a form. It's
OK though, I found a different method to achieve the same thing.
I posted the solution in thread "Report Header Variable" in this forum.
Thanks very much for your response.
So what you read does not apply to your situation.
--
Ken Snell
<MS ACCESS MVP>
"Sky Warren" <SkyW...@discussions.microsoft.com> wrote in message
news:6D63B104-9FAB-40CF...@microsoft.com...
I tried it with Access 2003, and it does not seem to work. I coded the
following:
DoCmd.OpenReport "rptQualStat", acViewPreview, , , , "28"
I tried to read it in the report_open event. I also tried the
report_activate. In both cases openargs returns Null.
OpenArgs works on Forms, but I don't believe the OpenReport syntax allows
for it. Another approach is to have the report "point at" (refer to) the
form in which you are trying to open the report. You can use the expression
(untested aircode, your syntax may vary):
Forms!frmYourForm!txtYourTextField
to let the report "see" the value.
Or perhaps you could open the report with a "filter" or "where" condition,
which are part of the OpenReport syntax...
--
Good luck
Jeff Boyce
<Access MVP>
"Leif" <Le...@discussions.microsoft.com> wrote in message
news:6ACD2C98-1090-426E...@microsoft.com...
FYI - OpenArgs for reports was a new feature in AXP.
--
Marsh
MVP [MS Access]
Yeah.. I posted that exact info a few notes up...Jeff musta not seen it < g
--
Ken Snell
<MS ACCESS MVP>
"Leif" <Le...@discussions.microsoft.com> wrote in message
news:6ACD2C98-1090-426E...@microsoft.com...
Now here is an interesting one for you. Openargs does not work for reports
as a positional parameter, but it does work as a named parameter! I got the
idea from seeing someone's post where they used a named parameter. By the
way, I'm using Access 2003 (XP). I'm picking up the parameter in report_open.
This does not work:
DoCmd.OpenReport "rptQualStat", acViewPreview, , , , "28"
But this does work:
DoCmd.OpenReport "rptQualStat", acViewPreview , OpenArgs:="28"
Regards,
Leif
Ken Snell
<MS ACCESS MVP>
"Leif" <Le...@discussions.microsoft.com> wrote in message
news:46FCAFA8-0D49-467D...@microsoft.com...
Jeff
"Ken Snell [MVP]" <kthsne...@ncoomcastt.renaetl> wrote in message
news:uPT6RCZ...@TK2MSFTNGP09.phx.gbl...
What indicates to you that the first step doesn't work? Did you read the
value of OpenArgs in the report's Open event? What value do you get? What
code are you running there?
--
Ken Snell
<MS ACCESS MVP>
"Leif" <Le...@discussions.microsoft.com> wrote in message
news:46FCAFA8-0D49-467D...@microsoft.com...
-keaven
Ken Snell [MVP] wrote:
> Interesting is a good word for it. Seems weird... I use OpenArgs parameters
> regularly in my ACCESS 2002 reports and do not specify the argument name; I
> always do it via the 6th argument in the list.
--
-----------------------------------------------------------------------
Keaven Freeman "There's no place like 127.0.0.1"
usenet[@]keaven[.]com ICQ: 35133457
http://www.keaven.com IM: KeavenMJ
"The box said 'Requires Windows 95 or better' ... so I installed Linux"
-----------------------------------------------------------------------
Sorry for such a late post. Using OpenArgs was a real pain but I got a
workaround from someone else "don't remember who".
What I initially wanted was to have a agents name appear in the header
section of all my reports without hardcoding that name into every report. I
ended up creating a new module with a public function in it which looks like
this:
Public Function AgentFull() As String
AgentFull = "John Doe"
End Function
Then, in the header section of each report is a text box with the following
as the Control Source:
=AgentFull()
Thus, "John Doe" appears in the header of every report. Plus, if I need to
change that name I only need to edit the module that contains the public
function. This works far better than fooling around with OpenArgs, which I
never got to work correctly.
I had problems at first though. I was trying to create the public function
inside the main form, THAT APPROACH WON'T WORK. Once I created the standalone
module and put the function inside, it worked great!!! Trial and error but
this is how we learn ;-)
As always, thanks to all who responded and tried helping another lost amatuer.
-Sky
You posted
DoCmd.OpenReport "Clients", acViewPreview, , , Agent_Name
Should be
DoCmd.OpenReport "Clients", acViewPreview, , , , Agent_Name
--
Ken Snell
<MS ACCESS MVP>
"Sky Warren" <SkyW...@discussions.microsoft.com> wrote in message
news:032CA45B-F37D-401B...@microsoft.com...