473,396 Members | 1,783 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,396 software developers and data experts.

How can I call a module from an event

1
I created a module from a DTS package in SQL Server. Basically I want to run the DTS package by clicking a button on an Access form. The DTS package is simply populating a table in SQL Server from a query in the Access database.

From another person's answer, I have saved the DTS pkg as a visual basic file (.bas) and imported it into Access as a module.

I then created a form and placed a button on it and I want to run the Access module (basically running the DTS pkg) by calling the module but don't know how to do it. Can someone help?

The VBA code for the button is:

Private Sub Command1_Click()

End Sub

The module name is called: DocInfoExport

Thanks
May 21 '07 #1
2 6180
JConsulting
603 Expert 512MB
I created a module from a DTS package in SQL Server. Basically I want to run the DTS package by clicking a button on an Access form. The DTS package is simply populating a table in SQL Server from a query in the Access database.

From another person's answer, I have saved the DTS pkg as a visual basic file (.bas) and imported it into Access as a module.

I then created a form and placed a button on it and I want to run the Access module (basically running the DTS pkg) by calling the module but don't know how to do it. Can someone help?

The VBA code for the button is:

Private Sub Command1_Click()

End Sub

The module name is called: DocInfoExport

Thanks

inside the module there should be a function or sub name that kicks off the DTS. You will need to call it vs trying to call the module name. You call a function by name.
Private Sub Command1_Click()
myfunctionname
End Sub
May 22 '07 #2
ADezii
8,834 Expert 8TB
I created a module from a DTS package in SQL Server. Basically I want to run the DTS package by clicking a button on an Access form. The DTS package is simply populating a table in SQL Server from a query in the Access database.

From another person's answer, I have saved the DTS pkg as a visual basic file (.bas) and imported it into Access as a module.

I then created a form and placed a button on it and I want to run the Access module (basically running the DTS pkg) by calling the module but don't know how to do it. Can someone help?

The VBA code for the button is:

Private Sub Command1_Click()

End Sub

The module name is called: DocInfoExport

Thanks
  1. You do not call a Module - you call Sub or Function Procedures contained within a Module.
  2. I dug up some sample code showing how to Execute a DTS Package from Visual Basic. I'm not sure what you would have to set your Library Reference to in this case, but if you're familiar with DTS Packages, I'm sure you will know.
  3. In the sample code below, you could simply execute the Sub Routine via Call RunPackage().
    Expand|Select|Wrap|Line Numbers
    1. Private WithEvents mobjPkgEvents As DTS.Package
    2. . . .
    3. Public Sub RunPackage()
    4. 'Run the package stored in file C:\DTS_UE\TestPkg\VarPubsFields.dts.
    5. Dim objPackage      As DTS.Package2
    6. Dim objStep         As DTS.Step
    7. Dim objTask         As DTS.Task
    8. Dim objExecPkg      As DTS.ExecutePackageTask
    9.  
    10. On Error GoTo PackageError
    11. Set objPackage = New DTS.Package
    12. Set mobjPkgEvents = objPackage
    13. objPackage.FailOnError = True
    14.  
    15. 'Create the step and task. Specify the package to be run, and link the step to the task.
    16. Set objStep = objPackage.Steps.New
    17. Set objTask = objPackage.Tasks.New("DTSExecutePackageTask")
    18. Set objExecPkg = objTask.CustomTask
    19. With objExecPkg
    20.     .PackagePassword = "user"
    21.     .FileName = "C:\DTS_UE\TestPkg\VarPubsFields.dts"
    22.     .Name = "ExecPkgTask"
    23. End With
    24. With objStep
    25.     .TaskName = objExecPkg.Name
    26.     .Name = "ExecPkgStep"
    27.     .ExecuteInMainThread = True
    28. End With
    29. objPackage.Steps.Add objStep
    30. objPackage.Tasks.Add objTask
    31.  
    32. 'Run the package and release references.
    33. objPackage.Execute
    34.  
    35. Set objExecPkg = Nothing
    36. Set objTask = Nothing
    37. Set objStep = Nothing
    38. Set mobjPkgEvents = Nothing
    39.  
    40. objPackage.UnInitialize
    41. End Sub
May 22 '07 #3

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

Similar topics

0
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft...
7
by: Tim ffitch | last post by:
Hi I have created a VB dll file that contains common functions I use across various projects in VB, Access and Excel. Rather than have to code the functions in each I decided to use the dll...
4
by: Shimon Sim | last post by:
I am working with ASP.NEt application and need to create something like notification module. Application passes a event information and module decides how to handle this event - who to notify and...
2
by: tonytony24 | last post by:
Hi All: I was wondering if there's a simple way to call a MS Access Module through either Command Prompt MS Script any other way... Thanks for the response.
3
by: Bryan | last post by:
I pass my form's collection of controls to a public sub in a module that loops through and checks for any ErrorProvider text. The sub returns all the ErrorProvider strings that were found for...
3
by: pvveeramani | last post by:
Hi Is there a way that I can call a method in an EXE (managed code, VB.NET) from a .NET DLL by passing a reference to the instance of the EXE? Multiple instances of EXE might be running and...
3
by: Anoop | last post by:
Hi All, I have a GUI module written in Delphi32. There is another main application written in CSharp.Net. I want to call the delphi GUI Form from with in CSharp.Net Code. The .Net application will...
4
by: otterbyte | last post by:
Hi, I have a bit of code which is confusing me to no end. Here are the basics: 1) The class module is being used in the module of a form. 2) There is an instance of the object declared at the...
6
by: RandomElle | last post by:
Hi there I'm hoping someone can help me out with the use of the Eval function. I am using Access2003 under WinXP Pro. I can successfully use the Eval function and get it to call any function with...
1
by: AMD_GAMER | last post by:
Hi, I am trying to print address labels. I have a form which asks for the user to input the first name, middle initial, and last name. On the button click to print the label, I have an event...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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: 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...
0
marktang
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.