I am trying to run a VBA script that will Run and Export an Access query. I'm able to get to the step in code where I run the query, however, I need to connect to DB2 to run this query in Access and I don't know how to implement into my code to enter the username and password.
Sub RunQuery()
Dim A As Object
Application.DisplayAlerts = False
Set A = CreateObject("Access.Application")
A.Visible = False
A.OpenCurrentDatabase ("J:\user\filename.mdb")
A.DoCmd.OpenQuery "QueryName"
A.DoCmd.ConnectString
Application.DisplayAlerts = True
End Sub
The code just stalls at the line:
A.DoCmd.OpenQuery "QueryName"
And If I open my Database from here with my query it is just waiting for my username and password. I'll try and attach a picture of the prompt.
Any help would be greatly appreciated!!
