Ms Access 2010 - Triggering a SSIS package - Runtime Error - ssis

I have landed in what I call a "wierd" situation. I have this snippet of code, which is used to trigger a SSIS package at stored in a particular location :
Dim sDTSfile As String
Dim dtexecStr As String
Dim sSourcePath As String
sSourcePath = "source path location"
sDTSfile = "dtsx package location"
dtexecStr = "dtexec /f """ & sDTSfile & """ /set
""\Package.Variables[User::Directory].Properties[Value];" & sSourcePath & """"
Set WshShell = CreateObject("WScript.Shell")
This snippet runs good in MS Access 2007, but as apart of the upgrade to MS Access 2010, I was testing the functionality of the code, and the code burps at this point
WshShell.Run dtexecStr, 1, True
Is there something that I am doing wrong in this case, If yes, ideally when the code is working in 2007, it should be functioning good in the upgraded 2010 even.
Thank you in advance!
The error meesage:
Method 'Run' of Oject 'IWshShell3' failed. Runtime error - 2147024894 (80070002)

Related

Failed VBA SQL Query in Outlook 365?

I have some VBA code in Outlook that runs a SQL query and populates a userform I designed. This code was previously running fine on one PC, then I was issued a new laptop and I copied the outlook VBA module directly over.
When I try to run, I just get an error "Compile Error: Can't find project or library" and the text "adOpenStatic" in the RS.open statement is highlighted. Previously, I had seen the same error if my SQL query was bad or the driver was missing, but I double checked both. I copied the EXACT code into an excel VBA module and it ran as expected.
The only other difference I can see is that I went from Outlook 2019 to Office 365 for Enterprise.
Dim server, database, login_user, password, port As String
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strSQL As String
server = "dummy"
database = "dummy"
login_user = "dummy"
password = "dummy"
port = "dummy"
Set cn = New ADODB.Connection
cn.ConnectionString = "DRIVER={MySQL ODBC 8.0 ANSI Driver};Provider=MSDASQL;" & "SERVER=" & server & ";" & " DATABASE=" & database & ";" & "UID=" & login_user & ";PWD=" & password & "; OPTION=3; PORT=" & port & ";Connect Timeout=20;"
'open the connection
cn.Open
Set rs = New ADODB.Recordset
strSQL = "SELECT * FROM quote WHERE id = 1505"
rs.Open strSQL, cn, adOpenStatic
With rs
Do Until .EOF
'parse out relevant project information
rs.MoveNext
Loop
End With
rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing
I can run the exact query in MySQL workbench, and it works as expected. The fact that the identical code can run in Excel without issue tells me there is perhaps a syntax difference in Outlook that I am unaware of? Anyone else have ideas?
NOTE, if it wasn't already obvious, I am omitting my database details with "Dummy", but the real code has the correct strings.
This code was previously running fine on one PC, then I was issued a new laptop and I copied the outlook VBA module directly over.
You need to re-add all COM references you had on the old machine.
From the Tools menu, choose References to display the References dialog box.
The References dialog box shows all object libraries registered with the operating system. Scroll through the list for the application whose object library you want to reference. If the application isn't listed, you can use the Browse button to search for object libraries (*.olb and .tlb) or executable files (.exe and *.dll on Windows). References whose check boxes are selected are used by your project; those that aren't selected are not used, but can be added.
Go to the VBA Editor, and choose Tools-References; and tick the box next to 'Microsoft ActiveX Data Objects' (the latest version). It should compile ok now.

MS Access macro for exporting to Excel hits limit of 65k records

I have a macro (created with the macro wizard) which runs a number of queries and then outputs a table to excel. The table has more then the 65,000 records limit for exporting formatted tables. How can I export the table without formatting in the macro? Here is the error I receive after I run the macro.
I know you are using access vba to export the records but have you thought about using a datalink to your query from excel and using the access vba to open the excel file and refresh the data table? this will definitely eliminate any issues with max rows and should not have any failure issues due to export size. If you need more info on how to do that let me know and I'll add more info here.
Here is the code requested by Anthony Griggs above. But it is a VBA solution, not a macro solution, so not directly responsive to the question as posted. This was how I worked around the problem and have had this successfully in production for a long time.
Be sure to add the reference to "Microsoft ActiveX Data Objects 2.8 Library" (or current version for you) and also the "Microsoft Excel 12.0 Object Library" (or current version for you) before using this code. The save changes and quit at the end are critical, otherwise it leaves Excel open in the background that you have to kill via task manager.
Dim rs As New ADODB.Recordset
Dim xl As New Excel.Application
Dim xlWb As Excel.Workbook
Dim xlRange As Excel.Range
xl.Visible = False
xl.ScreenUpdating = False
vcurfilename = "MyFilename.XLSX”
Set xlWb = xl.Workbooks.Open(vcurfilename, 0, False, 5, "password", "password")
rs.Open "Select * from qryMyAccessQuery", CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
Set xlRange = xlWb.Worksheets("MyExcelSheetName").Range("A1").Offset(1, 0)
xlWb.Sheets("MyExcelSheetName ").Range("a2:bq25000").ClearContents
xlRange.Cells.CopyFromRecordset rs
xl.Range("Table1").Sort key1:=xl.Range("Table1[[#All],[MyColumnName]]"), _
order1:=xlAscending, Header:=xlYes
On Error Resume Next
xl.Range("table1").Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
On Error GoTo 0
rs.Close
xl.Range("table1").ListObject.HeaderRowRange.Find("MyColumnName1").EntireColumn.NumberFormat = "dd-MMM-yy"
xl.Range("table1").ListObject.HeaderRowRange.Find("MyColumnName2").EntireColumn.NumberFormat = "dd-MMM-yy"
xl.Range("table1").ListObject.HeaderRowRange.Find("MyColumnName3").EntireColumn.NumberFormat = "dd-MMM-yy"
xlWb.Close SaveChanges:=True
xl.Quit
DoEvents

MS Access 2010 now asks for parameters on form load

I've been writing MS Access apps for a long time. I just switched to Access 2010 and now wherever I open a form in which I'm creating the InputParameters in code, the app prompts me to enter the parameters. I'm baffled and can't figure this out.
The following code has worked on all previous versions of MS Access until Access 2010:
Dim strRS As String
Dim lngID as Long
Dim intSomethignElse as Integer
strRS = "dbo.StoredProcedureName"
lngID = 1
intSomethignElse = 2
Forms!SomeFormName.InputParameters = "#parameter1 = " & lngID & ", #parameter2 = " & intSomethignElse
'Verify the parameters do indeed exist and they do:
Debug.Print Forms!SomeFormName.InputParameters
Forms!SomeFormName.RecordSource = strRS
Now when the form loads I get prompted to enter #parameter1 and #parameter2.
How do I get this to work again in MS Access 2010?
Any help is appreciated.
I had the similar VBA code. It worked fine in Access 2010 until recently and I got the same issue as the pop up window asking for parameters.
After I change the code to simliar to
Forms!SomeFormName.RecordSource = "exec dbo.StoredProcedureName #parameter=" & lngID
as Remou suggested in the comments, my application works again.
May be the RecordSource is not empty. Make sure it is empty in design view.
EDIT:
msdn says: The stored procedure should be executed using a command string containing the {call } syntax with one ? marker for each non-default parameter in the InputParameters list.
I do not know the call syntax, but I would try something like this:
strRS = "exec dbo.StoredProcedureName ?, ?"

Help Debugging this Code to Convert for .adp file type

I had a form with some VB code that was using Access 2003. Recently we wanted to use the same form as a small front end interface for another database that has a SQL Server backend. However, the file type for this project in Access is .adp and not all of the vb code is working properly. If you could help me fix the bugs in this code:
Private Sub SurveyNameCombo_AfterUpdate()
Dim db_CFC As DAO.Database
Set db_CFC = CurrentDb
Dim rst As DAO.Recordset, query As String, count As Integer
query = "SELECT DISTINCT SurveyID FROM tbl_SurveyMeta WHERE SurveyName = " & Chr(34) & Me.SurveyNameCombo.Value & Chr(34)
Set rst = db_CFC.OpenRecordset(query)
count = rst.RecordCount
If count > 1 Then
Me.SurveyIDCombo.RowSource = query
Else
rst.MoveFirst
Me.SurveyIDCombo.Value = rst.Fields(0).Value
Call SurveyIDCombo_AfterUpdate
End If
End Sub
It is throwing errors in the for the DAO.Database and DAO.Recordset.
Thank you for your help!
The error message "User-defined type not defined" on a line such as this ...
Dim db_CFC As DAO.Database
... means your application doesn't include a reference to the Microsoft DAO Object Library.
Open a code module, then check from the main menu in the VBE editor: Tools->References
Ordinarily the cure would be to place a check mark in the box next to Microsoft DAO Object Library, then click OK. However, your application is an ADP, and I don't know whether DAO can even be used in ADP. You can try. :-)
Sorry I can't tell you more. I quit using ADP a few years ago. Instead I use the MDB format with ODBC links to SQL Server database objects. Perhaps you could consider the same approach if you're unable to get the ADP version working as you need.

Access 2003 via Citrix: 'Error Loading DLL' with CurrentProject.Connection

Set up an Access Project to be opened via Citrix. However, there is some VBA code that prevents it from working:
Dim rs As ADODB.Recordset
Set rs = CurrentProject.Connection.Execute("Query")
The .Connection bit is highlighted. This works when it is not opened via Citrix though (i.e. just on users desktop).
Problem was due to the Citrix server not having the latest Jet Service Pack for Access.
I don't have a lot of experience with ADO but I'm thinking there's a references problem of some sort. Or that you are referencing a newer version of ADO on your system than is avaialble on the Citrix box. Run the following code and post back the results.
Sub ViewReferenceDetails()
Dim ref As Reference
For Each ref In Access.References
Debug.Print ref.Name & " - " & ref.Major & "." & ref.Minor & " - " & ref.FullPath
Next ref
End Sub
Also when you state Access project do you mean an ADP against SQL Server or an MDB/ACCDB against an Access data file?
Your code looks wrong to me. Should the rs Object not be a Recordset?
i.e.
Dim rs As ADODB.Recordset
'Instead of
Dim rs As ADODB.Connection
The code should not run at all - you should receive a Type Mismatch error.