stubblyhead
MIS
I am trying to open access reports from my visual basic application. this in itself is not much of a problem, but there are some small problems i'd like to take care of.
first off, some of my reports are based on parameter queries. i'd like to pass these parameters to the reports automatically, but i'm not sure how to do it. i tried playing around with the OpenArgs argument of the OpenReports method, but I got a type mismatch. Is this where I put my parameter, or am i going in the wrong direction? if so, what format does it want to be in? here's a code snippet of what i'm trying:
objAccess.DoCmd.OpenReport "repCustomer Receipt", acViewPreview, "", "", "", Val(datAccountsReceivable.Recordset!customerid)
where the customerID field holds the data i want to pass as a parameter.
secondly, the way i'm doing this creates the potential for huge memory leaks. what i'm doing is creating an access.application object, setting it to my db, and then using DoCmd.OpenReport. this is all good and well, and if the user does what I want them to, then there are no problems. but if the user closes the access application, then an instance of the access process remains in memory even after using the Quit method and setting the object to nothing. Each instance uses about 12mb of memory, so it wouldn't take too many before a system would grind to a halt. what can I do to deal with this? my code follows.
Set objAccess = CreateObject("access.application"
objAccess.Visible = True
objAccess.OpenCurrentDatabase gcstrDatabase
objAccess.DoCmd.OpenReport strReportName, acViewPreview, "", ""
MsgBox "Click OK when done.", vbOKOnly
objAccess.Quit
Set objAccess = Nothing
also, i'm only using that message box to keep the report from immediately closing. is there a more graceful way to do this? if i can do away with this message box and deal with the memory leak issue at the same time that would be wonderful. any and all help will be greatly appreciated.
Mike
first off, some of my reports are based on parameter queries. i'd like to pass these parameters to the reports automatically, but i'm not sure how to do it. i tried playing around with the OpenArgs argument of the OpenReports method, but I got a type mismatch. Is this where I put my parameter, or am i going in the wrong direction? if so, what format does it want to be in? here's a code snippet of what i'm trying:
objAccess.DoCmd.OpenReport "repCustomer Receipt", acViewPreview, "", "", "", Val(datAccountsReceivable.Recordset!customerid)
where the customerID field holds the data i want to pass as a parameter.
secondly, the way i'm doing this creates the potential for huge memory leaks. what i'm doing is creating an access.application object, setting it to my db, and then using DoCmd.OpenReport. this is all good and well, and if the user does what I want them to, then there are no problems. but if the user closes the access application, then an instance of the access process remains in memory even after using the Quit method and setting the object to nothing. Each instance uses about 12mb of memory, so it wouldn't take too many before a system would grind to a halt. what can I do to deal with this? my code follows.
Set objAccess = CreateObject("access.application"
objAccess.Visible = True
objAccess.OpenCurrentDatabase gcstrDatabase
objAccess.DoCmd.OpenReport strReportName, acViewPreview, "", ""
MsgBox "Click OK when done.", vbOKOnly
objAccess.Quit
Set objAccess = Nothing
also, i'm only using that message box to keep the report from immediately closing. is there a more graceful way to do this? if i can do away with this message box and deal with the memory leak issue at the same time that would be wonderful. any and all help will be greatly appreciated.
Mike