473,386 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Call access vb from another program

Hello all,

I have an accessdb and it can create a report from scratch with a button and a lot of vb. I want to automise the reporting. Therefore I want to call the vb sub making the report from another program. (another vbprogram or java or any programminglanguage) When I have that program I can call it in a scheduler and thereby have automised the reporting system.

I have searched for this for a while but I couldn't find anything. Does anyone know if this is possible or not??
Feb 16 '07 #1
5 3387
nico5038
3,080 Expert 2GB
You can make the Access .mdb self executing by using the Autoexec macro or a form that's used as the startup form and executes the code and closes the .mdb.

Such a .mdb can be scheduled, no other language needed.

Nic;o)
Feb 16 '07 #2
NeoPa
32,556 Expert Mod 16PB
Application Automation may help you to run things from outside of Access.
Bear Nico's reply in mind though. Automation is more complicated and is probably not necessary in your case.
Feb 18 '07 #3
ADezii
8,834 Expert 8TB
Hello all,

I have an accessdb and it can create a report from scratch with a button and a lot of vb. I want to automise the reporting. Therefore I want to call the vb sub making the report from another program. (another vbprogram or java or any programminglanguage) When I have that program I can call it in a scheduler and thereby have automised the reporting system.

I have searched for this for a while but I couldn't find anything. Does anyone know if this is possible or not??
I do believe that I have the answer to your question. The following code examples will execute a Public Function within an Access Database (C:\Test Directory\Test.mdb) via a Command Button on an Excel Spreadsheet. This is a simple example of Automation with Access acting as an Automation Server.
1. Within Excel set a Reference to the specific Access Object Library. In this case the Reference will be to the Microsoft Access 9.0 Object Library.
Expand|Select|Wrap|Line Numbers
  1. 'Place in Declarations Section of Excel Module
  2. Dim objAccAuto As Access.Application
Expand|Select|Wrap|Line Numbers
  1. 'In the Click() Event of a Command Button in an Excel Spreadsheet
  2. Private Sub CommandButton1_Click()
  3. Dim strProjectName As String
  4. Dim strProcedureToRun As String
  5.  
  6. 'Create an Instance of an Access Aplpication 2000 Object
  7. Set objAccAuto = CreateObject("Access.Application.9")
  8.  
  9. 'Open Test.mdb in a Microsoft Access Window in Exclusive Mode
  10. objAccAuto.OpenCurrentDatabase "C:\Test Directory\Test.mdb", True
  11.  
  12. 'Get the Project Name referring to the Database
  13. strProjectName = objAccAuto.GetOption("Project Name")
  14.  
  15. 'The name of the "Public" Function to Run in Test.mdb consists of
  16. 'ProjectName.FunctionName
  17. strProcedureToRun = strProjectName & ".fTestAutomation"
  18.  
  19. 'Run the Function
  20. objAccAuto.Run strProcedureToRun
  21.  
  22. Set objAccAuto = Nothing
  23. End Sub
Expand|Select|Wrap|Line Numbers
  1. 'Demo Function in Access Database (Test.mdb)
  2. Public Function fTestAutomation()
  3. Dim T As Long
  4.  
  5. Open "C:\Test Directory\Auto.txt" For Append As #1
  6.  
  7. For T = 1 To 100
  8.   Write #1, "Line #" & Str(T) & " ==> " & T ^ 2
  9. Next T
  10.  
  11. Close #1
  12. End Function
Expand|Select|Wrap|Line Numbers
  1. 'Sample Output
  2. "Line # 1 ==> 1"
  3. "Line # 2 ==> 4"
  4. "Line # 3 ==> 9"
  5. "Line # 4 ==> 16"
  6. "Line # 5 ==> 25"
  7. "Line # 6 ==> 36"
  8. "Line # 7 ==> 49"
  9. "Line # 8 ==> 64"
  10. "Line # 9 ==> 81"
  11. "Line # 10 ==> 100"
  12. "Line # 11 ==> 121"
  13. "Line # 12 ==> 144"
  14. "Line # 13 ==> 169"
  15. "Line # 14 ==> 196"
  16. "Line # 15 ==> 225"
  17. "Line # 16 ==> 256"
  18. "Line # 17 ==> 289"
  19. "Line # 18 ==> 324"
  20. "Line # 19 ==> 361"
  21. "Line # 20 ==> 400"
  22. "Line # 21 ==> 441"
  23. "Line # 22 ==> 484"
  24. "Line # 23 ==> 529"
  25. "Line # 24 ==> 576"
  26. "Line # 25 ==> 625"
  27. "Line # 26 ==> 676"
  28. "Line # 27 ==> 729"
  29. "Line # 28 ==> 784"
  30. "Line # 29 ==> 841"
  31. "Line # 30 ==> 900"
  32. "Line # 31 ==> 961"
  33. "Line # 32 ==> 1024"
  34. "Line # 33 ==> 1089"
  35. "Line # 34 ==> 1156"
  36. "Line # 35 ==> 1225"
  37. "Line # 36 ==> 1296"
  38. "Line # 37 ==> 1369"
  39. "Line # 38 ==> 1444"
  40. "Line # 39 ==> 1521"
  41. "Line # 40 ==> 1600"
  42. "Line # 41 ==> 1681"
  43. "Line # 42 ==> 1764"
  44. "Line # 43 ==> 1849"
  45. "Line # 44 ==> 1936"
  46. "Line # 45 ==> 2025"
  47. "Line # 46 ==> 2116"
NOTE: You can use this same functionality in any Client Application that supports Automation. Too tired - going to sleep now. Hope this helped.
Feb 18 '07 #4
Hello,

Thank you all for your replies. I havn't tested any of your solutions yet but i'm sure that they will help me greatly.
Feb 22 '07 #5
NeoPa
32,556 Expert Mod 16PB
Maarten,
If you do manage to find a solution that fits your needs (from anywhere not just the solutions posted here), and you get the time, we'd be interested to hear how you get on.
That helps others who come searching to know whether or not the solutions are reliable.
Feb 22 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: jaykchan | last post by:
I would like to know how to call various routines dynamically using VB.NET. Let say I have a class called CMyBarcodeReader that needs to send a barcode number that it has received from scanner...
7
by: Malcolm Cook | last post by:
Hi, I've created and installed a custom UDF to populate my combobox, and have defined it per :...
35
by: deko | last post by:
Do I get more scalability if I split my database? The way I calculate things now, I'll be lucky to get 100,000 records in my Access 2003 mdb. Here some math: Max mdb/mde size = 2000 x 1024 =...
4
by: Dave | last post by:
I have a program that I've written a class for. I need to call the function in the program from the class. When I try to call the function I receive the error, the name xxx does not exist in the...
5
by: B1ackwater | last post by:
We've fooled around with Access a bit, but only using the single-user store-bought version. It seems to be a good database - versatile and infinitely programmable - and can apparently be used as a...
7
by: Steve_Black | last post by:
Hello, I'm toying with the idea of loading a MenuStrip (VB.Net 2005) dynamically based on who is logged into my system. Every user has different security settings and I want to customize the...
11
by: c676228 | last post by:
Hi everyone, I am just wodering in asp program, if there is anybody writing store procedure for inserting data into database since there are so many parameters need to be passed into store...
1
by: qilin | last post by:
I have perl program which use system() to call another c program meanwhile the c program also use system() to execute a linux command line ....but not sure why it doesn't work. yes, the perl...
2
by: =?Utf-8?B?SmltIE93ZW4=?= | last post by:
Hi John, Hopefully this post will find its way back to you - or perhaps be answered by someone else. As I mentioned in my last post on the earlier portion of this thread, changing the...
0
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,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.