![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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 |
![]() |
| Thread Tools | |
| Display Modes | |
| |