Powershell Interaction with Access 2007, how to Save Report as PDF? - ms-access

I have an access database and a report in that database. I am using the access.application comobject to gain access to access, i.e.
$db = New-Object -ComObject Access.Application
$db.OpenCurrentDatabase("foo.accdb")
This works fine. However, as suggested in another similar question I am unable to get the report out of the db by using the DoCmd.OutputTo method.
$db.DoCmd.OutputTo(3,"The_Report","acFormatPDF","C:\The_Report.PDF")
When I execute that above command, and error returns stating that:
Exception calling "OutputTo" with "4" argument(s): 'The format in which you are attempting to output the current object is not available."
I have ensured that the "save to pdf" add-on is installed. Beyond that, I am unable to figure out what is stopping this object from being output in the requested format. Am I missing something?

acFormatPDF is a constant, so putting the constant name in quotes seems wrong. I tried without the quotes, but Powershell doesn't appear to recognize the constant. So I tried the string value for that constant, in quotes, and it worked.
I'm basically lost with this Powershell thing, but suggest you try:
$db.DoCmd.OutputTo(3,"The_Report","PDF Format (*.pdf)","C:\The_Report.PDF")

Related

Issue running reading a JSON file then creating a new one in the same LotusScript agent

I have a Lotusscript agent that calls one subroutine to read a JSON file using the following line:
Set jsnav = session.CreateJSONNavigator(json)
After that subroutine is done, I call another subroutine that creates a new JSON file using the following:
Set jsonNav = session.Createjsonnavigator("")
When this agent is run from a Notes client it works great. When it is set to run as a scheduled agent on the server, I receive this error when 2nd line (above) is called:
Err=4240, error=Problem with input variant
What is causing this and why does it work on the client and not the server?

Data Studio Connector can't get access token for BigQuery Service Account: Access not granted or expired

I'm trying to make a community connector to connect my database in BigQuery to data studio with the service account that I hooked up as the Owner/DataViewer/JobUser of the BigQuery project. I know that the service account works when connecting to BigQuery because I've tested it elsewhere. I copied from the connector code from this tutorial (https://developers.google.com/datastudio/solution/blocks/using-service-accounts) almost exactly, replacing the SQL string with my query and adding some different query parameters. I also stored the service account's credentials in my script properties by pasting the json object and storing it like:
var service_account_creds_obj = {
"type": "service_account",
"project_id": ...
...
}
scriptProperties.setProperty('SERVICE_ACCOUNT_CREDS', JSON.stringify(service_account_creds_obj));
However, I always get stuck in the flow when my getData function calls getOauthService().getAccessToken(), which doesn't ever successfully return. When I create a report using the connector, I get this error: "Access not granted or expired." I can't find the documentation for getAccessToken and I'm having trouble understanding why it won't terminate. I can see that it doesn't return because a console.log immediately before that line displays but it never gets to the log on the next line. Then my try-catch block catches the error that I'm seeing. Note that my getOauthService function is exactly the same as the one from the documentation/tutorial example, except that I've played around with the input text in the call to createService. That input text shouldn't really matter though right?
Please, I've been trying to debug this for hours, but the documentation on this is pretty horrible, and it's really hard to debug since the flow of the code is handled in the background and stackdriver logging is really buggy.
I figured out my problem. The documentation posted above said to set the OAuth2 scope to https://www.googleapis.com/auth/bigquery.readonly. However, I naively included
"oauthScopes": ["https://www.googleapis.com/auth/bigquery.readonly"]
in my manifest file. Meanwhile, the code I copied over from the documentation already included this line:
.setScope(['https://www.googleapis.com/auth/bigquery.readonly']);
So I'm not sure exactly why this caused a problem. But it must have prevented the OAuth2.createService function from properly getting set.

Error when creating dynamic data source in SSRS

I am trying to create a dynamic data source in SSRS. I have a generic report that needs to be run across multiple database servers, requiring a way to connect to each based on a parameter.
I have setup my parameters in a way where I can generate the following connection string:
Data Source=172.16.1.111;Initial Catalog=TESTDB
If I plug that connection string into the "Connection String" text area field in the Data Source Properties window and click "Test Connection," I get the "Connection created successfully" message.
However, if I attempt to create an expression with the same data source (forget about the dynamic data source for a minute), like as shown below, I get a "The ConnectionString property has not been initialized" error message when trying to test the connection.
="Data Source=172.16.1.111;Initial Catalog=TESTDB"
Based on other examples I have seen looking this up online, this type of connection string definition is supposed to work.
My end goal is to create something like:
="Data Source=" + Parameter!Server.Value + ";Initial Catalog=" + Parameter!Database.Value
which would allow me to connect to any database based on the user selection.
Does anyone have any suggestions for what I might be doing wrong? I am using SQL Server 2014 Report Builder.
This ended up being an issue with the report builder. Once I deployed the report I was able to get this work. For some reason, even if you hard code the connection string as I mentioned above, expressions will not evaluate at runtime when running from within the report builder.
Hope this helps someone else in the future!

CurrentProject.OpenConnection Fails in MS Access 2000

I support a LOB application written in MS Access VBA with a SQL Server back end. One feature of the application is the ability to open a second instance of the application, allowing the users to view/modify two records at the same time.
The first time I open the application it connects and everything works fine. However when I attempt to open the second instance I get the following error message:
-2147467259 - Method "OpenConnection" of object _CurrentProject failed.
This is the line of code executing when the error occurs:
CurrentProject.OpenConnection strConnection
I have stepped through the code and verified that strConnection is the same connection string in both the first and second instances of the application
I'm running out of things to look for. Any ideas are greatly appreciated!
UPDATE: It appears that something is not allowing the second MSACCESS.EXE instance to use the same connection string. My connection string is below, with database and server substituted for the actual database and server.
PROVIDER=SQLOLEDB.1;INTEGRATED SECURITY=SSPI;PERSIST SECURITY INFO=FALSE;INITIAL CATALOG=database;DATA SOURCE=server
Try
MultipleActiveResultSets=True
(http://msdn.microsoft.com/en-us/library/h32h3abf(v=vs.110).aspx)
Would it be better to open a new form from the same application?
dim frm as ShowCar_Form
frm.Show

Error on Access database: Permission denied: 'CreateObject'

I am migrating a website over to a new server, its in ASP and uses several Access databases, the site and CMS can read, display the data, and even edit and update existing data entries, but when I want to add a new entry, I get an error...
Microsoft VBScript runtime error '800a0046'
Permission denied: 'CreateObject'
/padp2010d/ads_tradetracker.asp, line 11
There seems to be no passwords on the databases, I have set up and tested the ODBC Data Sources and they are working fine.
The code or line that is causing the problem is...
<%
Dim Mail, strPath, strHost, Upload
Set Upload = CreateObject("Persits.Upload")
Upload.IgnoreNoPost = True
' Generate unique names
Upload.OverwriteFiles = False
' Limit file size to 500000 bytes
Upload.SetMaxSize 500000, True
' capture an upload and save uploaded files (if any) in temp directory
Upload.SaveVirtual "\pa\images\advertenties"
Upload.Save
' Use session ID as the new file name
NewName = Session.SessionID
The line 11 is Set Upload = CreateObject("Persits.Upload")
If anyone could help that would be great. Could it be a Permission setting?
Im a complete novice with ASP and Access!
Thanks
I have tried the answer below but I still get an error...
Server object error ASP 0178 : 80070005
Server.CreateObject Access Error
/padp2010d/ads_tradetracker.asp, line 11
The call to Server.CreateObject failed while checking permissions. Access is denied to this object.
How about:
Server.CreateObject("Persits.Upload")
Try CreateObject("Persits.Upload", "localhost") instead. I've found that in some scenarios the optional argument is required, but have never figured out a pattern as to when.
I have now solved the problem, the script works fine, the problem was permission settings on AspUpload component on the server. Many Thanks for your help.