I am trying to call a module function in an Access db and then open a
report from a VB application. The problem I've found: I can't find a
good way to call a function that accepts arguments. I need to pass
arguments to set information that determines which information will
appear in the report.
Code Below:
MY argument accepting function:
Public Function SetCurrentIDs(PCaseID As String)
'Set the values if the pcase exists
If (DCount("PCaseID", "PCase", "PCaseID = '" & PCaseID & "'") = 1)
Then
MyCurrentPCaseID = PCaseID
MyCurrentPCaseIDAdden = DLookup("PCaseIDAdden", "PCase", _
"PCaseID = '" & PCaseID & "'")
MyCurrentPCaseIDAddenNo = DLookup("PCaseIDAddenNo", "PCase", _
"PCaseID = '" & PCaseID & "'")
MyCurrentStatus = DLookup("Status", "PCase", "PCaseID = '" & _
PCaseID & "'")
End If
End Function
MY VB code to call the above function and open a report:
Public Sub PrintAccessReport(dbName As String, _
rptname As String, _
preview As Boolean, _
eprsID As String)
Dim objAccess As Object
On Error GoTo PrintAccessReport_Err
Set objAccess = CreateObject("Access.Application")
With objAccess
.OpenCurrentDatabase filepath:=dbName
'.SetCurrentIDs eprsID
'BELOW ARE A FEW METHODS IVE UNSUCCESFULLY TRIED
.DoCmd.OpenModule "Globals", _
"SetCurrentIDs(""XXX"")"
.Run "SetCurrentIDs """ & eprsID & """"
If preview = True Then
.DoCmd.OpenReport reportname:=rptname, View:=acPreview
.Visible = True
.DoCmd.Maximize
.DoCmd.Maximize
.Globals.SetCurrentIDs
Else
.DoCmd.OpenReport reportname:=rptname, View:=acNormal
DoEvents
End If
End With
Set objAccess = Nothing
PrintAccessReport_Exit:
Exit Sub
PrintAccessReport_Err:
'LogCriticalError "PrintAccessReport"
Debug.Print Err.Number & " - " & Err.Description
Resume PrintAccessReport_Exit
End Sub
When I do try the Run or DoCmd functions to call my function I usually
get a "2517 - XXX can't find the procedure 'XXX.'" error.
Any Ideas? Any help is greatly appreciated.
Thanks for reading,
Adam 1 3387
Look at controlling Access via COM Automation. It is a
COM-Autpomation-enabled product. That is far too comprehensive a subject to
address in a newsgroup response.
You will have to learn the Access object model, but the VBA itself will be
familiar, because the VBA.DLL is the core language of classic VB, too.
Larry Linson
Microsoft Access MVP
"Adam Kramer" <ad****@gmail.com> wrote in message
news:d9**************************@posting.google.c om... I am trying to call a module function in an Access db and then open a report from a VB application. The problem I've found: I can't find a good way to call a function that accepts arguments. I need to pass arguments to set information that determines which information will appear in the report. Code Below:
MY argument accepting function: Public Function SetCurrentIDs(PCaseID As String) 'Set the values if the pcase exists If (DCount("PCaseID", "PCase", "PCaseID = '" & PCaseID & "'") = 1) Then MyCurrentPCaseID = PCaseID MyCurrentPCaseIDAdden = DLookup("PCaseIDAdden", "PCase", _ "PCaseID = '" & PCaseID & "'") MyCurrentPCaseIDAddenNo = DLookup("PCaseIDAddenNo", "PCase", _ "PCaseID = '" & PCaseID & "'") MyCurrentStatus = DLookup("Status", "PCase", "PCaseID = '" & _ PCaseID & "'") End If End Function
MY VB code to call the above function and open a report: Public Sub PrintAccessReport(dbName As String, _ rptname As String, _ preview As Boolean, _ eprsID As String) Dim objAccess As Object On Error GoTo PrintAccessReport_Err Set objAccess = CreateObject("Access.Application")
With objAccess .OpenCurrentDatabase filepath:=dbName '.SetCurrentIDs eprsID 'BELOW ARE A FEW METHODS IVE UNSUCCESFULLY TRIED .DoCmd.OpenModule "Globals", _ "SetCurrentIDs(""XXX"")" .Run "SetCurrentIDs """ & eprsID & """"
If preview = True Then .DoCmd.OpenReport reportname:=rptname, View:=acPreview .Visible = True .DoCmd.Maximize .DoCmd.Maximize .Globals.SetCurrentIDs Else .DoCmd.OpenReport reportname:=rptname, View:=acNormal DoEvents End If End With
Set objAccess = Nothing PrintAccessReport_Exit: Exit Sub PrintAccessReport_Err: 'LogCriticalError "PrintAccessReport" Debug.Print Err.Number & " - " & Err.Description Resume PrintAccessReport_Exit End Sub
When I do try the Run or DoCmd functions to call my function I usually get a "2517 - XXX can't find the procedure 'XXX.'" error.
Any Ideas? Any help is greatly appreciated.
Thanks for reading, Adam This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Muthu |
last post by:
I've read calling conventions to be the order(reverse or forward) in
which the parameters are being read & understood by compilers.
For ex. the following function.
int Add(int p1, int p2, int...
|
by: Glenn C. Rhoads |
last post by:
I'm having a problem calling a C function from a publicly available
library file. To get the code to compile, I had to declare the
function as an external C function as follows.
extern "C"...
|
by: Randell D. |
last post by:
Folks,
I'm sure this can be done legally, and not thru tricks of the trade - I
hope someone can help.
I'm writing a 'tool' (a function) which can be used generically in any
of my projects. ...
|
by: Sivakumar Shanmugam |
last post by:
Group.. We are running on db2 UDF V8 on Sun solaris platform. I
created an UDF which calles a C-routine(SQL_API_FN). This C-routine in
turn calls an external C-function. The C-function is provided...
|
by: Bill Grigg |
last post by:
I have been successfully calling DLL's using VC++ 6.0 and also using VC++7.1
(.NET). I only mention this because I have never felt comfortable with the
process, but nonetheless it did work....
|
by: leaf |
last post by:
How can i call arbirary functions at runtime, that with arbirary
parameters and types?
Can BOOST.Bind do that?
|
by: John Friedland |
last post by:
My problem: I need to call (from C code) an arbitrary C library
function, but I don't know until runtime what the function name is,
how many parameters are required, and what the parameters are. I...
|
by: Patient Guy |
last post by:
The code below shows the familiar way of restricting a function to be a
method of a constructed object:
function aConstructor(arg)
{
if (typeof(arg) == "undefined")
return (null);...
|
by: teju |
last post by:
hi,
i am trying 2 merge 2 projects into one project.One project is using c
language and the other one is using c++ code.
both are working very fine independently.But now i need to merge both...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |