borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Need help in Data Report)Next Topic (Formulas) New Topic New Poll Post Reply
AndreaVB Forum : Reporting tools : Help! Calling an Access 2002 Report with vb6
Poster Message
clod69
Level: Trainee

Registered: 20-10-2004
Posts: 3

icon Help! Calling an Access 2002 Report with vb6

I've got troubles calling an Access Report usin vb6 (os is win 98).
I used the docmd but it doesn't work.

I wonder of it because the same try with an Access 97 db works correctly!!!!

If someone can help me ....

Thank you  
Clod.

20-10-2004 at 07:30 AM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 536
icon Re: Help! Calling an Access 2002 Report with vb6

You will need to change the Access Library in your Project References to "Microsft Access 10.0 Object Library"


____________________________
multi-tasking - the ability to hang more than one app. at the same time.

20-10-2004 at 07:37 AM
View Profile Send Email to User Show All Posts | Quote Reply
clod69
Level: Trainee

Registered: 20-10-2004
Posts: 3
icon Re: Help! Calling an Access 2002 Report with vb6

quote:
GeoffS wrote:
You will need to change the Access Library in your Project References to "Microsft Access 10.0 Object Library"




Thank you for your help but when i did my try in access 2002 I also set the right library but i'm still having the problem!!

If you have any other suggestion ... thanks

Clod   
20-10-2004 at 07:42 AM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 536
icon Re: Help! Calling an Access 2002 Report with vb6

Try this Code :-
I have assumed that you have the Access Project in the same folder as the App so I have retrieved the path for the app first, rather than hard-coding a path.


Dim AcApp As Access.Application
Set AcApp = New Access.Application
Dim strPath As String

strPath = App.Path
strPath = strPath & "\reporting1.adp"

AcApp.OpenAccessProject strPath
AcApp.Visible = True
AcApp.DoCmd.OpenReport "YourReport1", acViewPreview
AcApp.DoCmd.Maximize

'don't forget to dispose of the object when you close the form you are calling from, _
'otherwise repeated calls will end up with loads of instances of MSAccess running on your PC

AcApp.Quit
Set AcApp = Nothing



If your Access is not an adp project but a standard "mdb" database then replace the open call with -
"AcApp.OpenCurrentDatabase strPath"




____________________________
multi-tasking - the ability to hang more than one app. at the same time.

20-10-2004 at 08:12 AM
View Profile Send Email to User Show All Posts | Quote Reply
cbremar
Level: Protégé

Registered: 26-10-2004
Posts: 7
icon Re: Help! Calling an Access 2002 Report with vb6

I am trying to call an Access '97 report from VB 6.  How would I go about doing that?  I have tried several sites and I can't seem to find anyone who can answer this question for me.

22-11-2004 at 04:36 PM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 536
icon Re: Help! Calling an Access 2002 Report with vb6

Hi,
Just follow the advice above, but you will need to change the Access Library in your Project References to "Microsoft Access 8.0 Object Library"
You obviously also need to have a copy of MS Access installed on the machine on which you are running your app.


____________________________
multi-tasking - the ability to hang more than one app. at the same time.

22-11-2004 at 04:40 PM
View Profile Send Email to User Show All Posts | Quote Reply
cbremar
Level: Protégé

Registered: 26-10-2004
Posts: 7
icon Re: Help! Calling an Access 2002 Report with vb6

Thank you.  I will try it.  I hope this works.

22-11-2004 at 04:52 PM
View Profile Send Email to User Show All Posts | Quote Reply
cbremar
Level: Protégé

Registered: 26-10-2004
Posts: 7
icon Re: Help! Calling an Access 2002 Report with vb6

I added the correct reference, my database gets opened in the form load, but the code doesn't work and I'm getting this error message:

Run-time error '2486':

You can't carry out this action at the present time. @You tried to run a macro or used the DoCmd object in Visual Basic to carry out an action.  However, Microsoft Access is performing another activity that prevents this action from being carried out now.
For example, no actions on a form can be carried out while Microsoft Access repainting a control or calculating an expression.@Carry out the action later.@1@@1

    

22-11-2004 at 06:09 PM
View Profile Send Email to User Show All Posts | Quote Reply
nick2k4000
Level: Big Cheese

Registered: 29-09-2003
Posts: 20
icon Re: Help! Calling an Access 2002 Report with vb6

quote:
GeoffS wrote:
Try this Code :-
I have assumed that you have the Access Project in the same folder as the App so I have retrieved the path for the app first, rather than hard-coding a path.


Dim AcApp As Access.Application
Set AcApp = New Access.Application
Dim strPath As String

strPath = App.Path
strPath = strPath & "\reporting1.adp"

AcApp.OpenAccessProject strPath
AcApp.Visible = True
AcApp.DoCmd.OpenReport "YourReport1", acViewPreview
AcApp.DoCmd.Maximize

'don't forget to dispose of the object when you close the form you are calling from, _
'otherwise repeated calls will end up with loads of instances of MSAccess running on your PC

AcApp.Quit
Set AcApp = Nothing



If your Access is not an adp project but a standard "mdb" database then replace the open call with -
"AcApp.OpenCurrentDatabase strPath"




17-12-2004 at 03:58 PM
View Profile Send Email to User Show All Posts | Quote Reply
cbremar
Level: Protégé

Registered: 26-10-2004
Posts: 7
icon Re: Help! Calling an Access 2002 Report with vb6

This seems to work, but how do I handle it when there is a password on the database?

17-12-2004 at 07:28 PM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 536
icon Re: Help! Calling an Access 2002 Report with vb6

Ah - Now that starts to get a bit awkward when the Database itself has a password on it. As far as I know there is no way to pass the password as a parameter when calling the open command. ( If I am wrong PLEASE someone tell me how to do it!!)
In the past I have used a SendKeys command after calling Open, and that has worked. Don't forget to include "~" at the end of the password for the "Enter" key.


____________________________
multi-tasking - the ability to hang more than one app. at the same time.

19-01-2005 at 10:38 AM
View Profile Send Email to User Show All Posts | Quote Reply
cbremar
Level: Protégé

Registered: 26-10-2004
Posts: 7
icon Re: Help! Calling an Access 2002 Report with vb6

Thanks for the help.  I am all set.

19-01-2005 at 02:08 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Reporting tools : Help! Calling an Access 2002 Report with vb6
Previous Topic (Need help in Data Report)Next Topic (Formulas) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder