Macro Single Step, Error 3270 - ms-access

Even though I'm new to access, things were progressing well, but I've hit the wall with a few issues. I've inherited a split database with four pieces, a backend version, frontend version and two user versions in accde form. The users wanted some changes, so I needed to add a few forms, modify a few forms, add a table and come up with the queries for the changes. That work is complete and I was able to convert the new frontend accdb version to the user accde versions. Some of the users are able to open the database, but some of the users are getting a Macro Single Step message with the following information;
Macro Name: AutoExec
Action Name: RunCode
Error Number: 3270
There's also a message about the backend location not being a valid path, but of course it is.
I'm wondering what the differences would be between the users who are able to get in and those that aren't. I've added the location to their trusted sites and I've changed their macro settings with no success.
Any thoughts would be appreciated, thanks, Bill

Related

SaveRecord error in Access template macro

I'm using a database based on the MS-Access Assets Database template. (You can download it here: https://support.microsoft.com/en-us/office/use-the-access-asset-tracking-template-6e99a32c-fbda-48a2-89b0-ef0d68b381ec.
I've added a few tables of my own and some VBA code.
On the "Asset Details" form, I can make a change to the current record, then press the "Save and New" button. It runs the embedded macro cmdSaveAndNew, which you can see here:
I have not modified this macro. But it gives me this error message:
The Microsoft Access database engine cannot find the input table or query 't Asset Log'. Make sure it exists and that its name is spelled correctly
So you know, t Asset Log is the old name of one of the tables that I added to the database. I cannot figure out why the embedded macro is trying to access it. (In the current version of the database, it's tAssetLog with no spaces. I've searched through my VBA code, and it only uses the current spacing.)
I tried the macro in "Single-step" mode. As near as I can tell, the error occurs at the SaveRecord line.
I've looked at the properties of all the controls, and I don't see any Data or Events that point to t Asset Log. I've run "Compact and Repair" on the database, and also compiled the code in the VBA editor; they didn't help.
open the queries involved with this macro and sanity check that 't Asset Log' is not being used as criteria or in a calculated field...
if you don't see it there, wouldn't hurt to search in VBA for 't Asset Log' - is easily done with the Find feature...but doesn't seem like is here though not sure what the macro does....

How can I create a trusted ACCDE Access file?

I would like to save an Access database as an ACCDE and also have it trusted. The reason being every time I open ACCDE I keep receiving the message:
"A potential security concern has been identified..."
I know that I can sign a ACCDC file with SelfCert.exe but thats not what I need.
I want the Access File to end with ACCDE and have the message:
"A potential security concern has been identified..." not show up.
You can create a registry key that will add the directory as a trusted location and will not show the warning anymore. What's nice about this method is that you can easily automate this to happen on the computers where you deploy your app. See method #2 or #3 in this blog: http://www.accessrepairnrecovery.com/blog/fix-microsoft-access-security-notice
And in case the blog ever gets removed, here is the important bits: [HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Access\Security\Trusted Locations\Location20] “Path”=”C:\Database\” “Description”=”My Database location”
Explanation about the key: – The number “14.0” is the version of MS Office. You can change the numbers that represent the version you are executing.
– The “Location20” is a unique name that you assign. 20 can be any number that is not previously used. Other programs include default MS Access wizards, already have used other numbers. But if you want to make more than one path as trusted location, then each location must end up with different number.
– The “C:\Database\” is the physical path that you want to set to be as Trusted Location. You can place any path that you choose here.
By copy and pasting the above coding into a text file and save it with a name such as RemoveSecurityWarning.reg, you can then run the file into your PC’s registry just by making double click on the file.

MS Access 2016 Login Page [duplicate]

So after some digging I realize that there is no built in user level security option for Access 2007. What I need to do is restrict records that users can edit based on who is logged in (they can see all the data but only edit their own). I was thinking that I could make a log in form and assign passwords and go from there, but I was wondering if there was a better method to do this.
For user privileges for read-only, read-write on forms in the database, we implemented following tables, logic.
I created a privilege table along with log-in table. Each screen in the database will have Read-only or Read-write privilege to each user. I inserted all the screen names into privilege table. Another table UserPrivilege will have users and their privileges. Assigning privilege to an user will be done only by Admin user.
A function at start of each form check swhether a specified user is allowed to view or edit form. If he/she is given read-only, we will lock all controls looping thr' controls on the form. Else, nothing to do. OR keep all the controls read-only at design them and unlock them thr' code for write privilege.
The database window is kept hidden when a version to end user is delivered. This prevents usual , simple view to tables in the database, opening forms , reports object in database window. After making mde/accde few more tweaks can be done so that user is not easily able to view tables directly. by-passing startup, special keys etc.
I have been facing this problem too. My solution (which hasn't been broken yet) is to do exactly that. Make a user's table with passwords and a log in form which reads the table for User name, password and user type. I have used two ways to proceed from there: Case statement to open specific navigation forms for that user's functions or a global variable (in a module (enumeration helps)) and an getter function that is checked within each form's open events and changes properties like AllowEdits, and AllowAdditions and even cancel the form opening if it's administrative stuff.
The most important part of this set up is making sure the users are using Access Runtime. If they use the Access version you are developing in they can snoop a little bit and get around this.
Make sure you hide the user's table.
Access runtime can be forced by making a shortcut to the DB and adding /runtime to the end of the shortcut path (with a space).
It's not perfect, but it works for my purposes and It might work for your's.
I did dot this in 2010, but 2007 should be pretty much the same.
Assigning username/passwords in Access (especially with an access back end) has a number of critical issues that are worth pointing out. Firstly, if you don't encrypt your DB, then any of your users who are savvy enough to go looking for it will be able to find it, and therefore get full access to it. If you encrypt the DB, if anyone can get access to your source code you're toast, since they will be able to see the DB user/passwords stored in the code. This issue persists if you use other SQL db's, but at least in those cases you can restrict the user supplied to the Access .accdb file to have certain permissions.
For my case, I have 3 levels of security. Firstly, I heavily restrict what I send out to make it very difficult to access the source code, which you kind of have to do no matter what. Secondly, I distribute different levels of access with different DB passwords (I'm using a MySQL back-end, you could do the same with a SQLServer back-end, but with Jet you're out of luck), so even if users could see the DB user and password, they are limited in what they can do. Thirdly, since I deploy on a corporate network, I take advantage of windows groups, and use those to filter out what is visible to different users. That way, users can only use the forms if they are authenticated onto our network. If the file discovers it's not on the network, it deletes itself and terminates.
Function IsMember(strDomain As String, strGroup _
As String, strMember As String) As Boolean
Dim grp As Object
Dim strpath As String
strpath = "WinNT://" & strDomain & "/"
Set grp = GetObject(strpath & strGroup & ",group")
IsMember = grp.IsMember(strpath & strMember)
End Function
Function GetCurrentUser() As String
GetCurrentUser = VBA.Environ$("USERNAME")
End Function
Function GetCurrentDomain() As String
GetCurrentDomain = VBA.Environ$("USERDOMAIN")
End Function

Access VBA: Update Reference Library with AutoExec macro, work's in accdb format but not when compiled?

Here is my VBA code to be executed in MS Access 2010. For simplicity I've removed error handling in this code. Function resides in a module with a different name.
Public Function ReAddLibrary()
Dim accessProj As Access.Application
Dim chkRef As Access.Reference '
Set accessProj = Access.Application
' Check through the selected references.
For Each chkRef In accessProj.References
' If the reference "MyReference" exists then remove.
If chkRef.Name = "MyReference" Then
accessProj.References.Remove chkRef
Exit For
End If
Next
‘ Add back the reference “MyReference” from specified location.
accessProj.References.AddFromFile "Access Database Path"
End Function
Adapted from
https://msdn.microsoft.com/en-us/library/aa221567(v=office.11).aspx
Premise
Users, use Access databases as the front end, naturally there’s an array of them. One thing in common is that they share reference to an accde database which houses shared functions. Naturally these databases are compiled to stop users getting at the VBA/Design mode. The database that is being referenced is also compiled. Currently work is being done to its accdb equivalent and every time it is published as an accde to the database location, an unresolved reference is created. The reference path hasn’t changed location (Nor will it). All recipient Accdb databases work fine, but their equivalent compiled versions throw a generic error when a button linked-subroutine is clicked for example.
If I use the above code as a subroutine linked to an on click event such as “On Load” for a form housing a button in question, this code works perfectly, even compiled. But if I convert this to a function and link it to a macro named “AutoExec,” it will execute the macro when opening the database but will.
Work in a non-compiled database
Will not work when database is compiled
The AutoExec macro route is because I just want this code pasted in once and executed once when the user opens the database, so the reference is recreated and not broken.
Macro
Action: RunCode
Function Name: ReAddLibrary ()
My thoughts
Initially, I’ve looked into late binding as a solution but I’m finding it hard to grasp as I don’t really code in VBA, I primarily code in sql and thus miss Intellisense and syntax highlighting. All examples are for excel workbooks making it difficult to relate. All my users and myself use the same Access 2010 so there is no version confliction. So I don’t know if this is the answer.
http://www.granite.ab.ca/access/latebinding.htm
I considered running a script to recompile all the user’s databases. But, work to the referenced database is incrementally on going and booting people off would be a nuisance.
Why, when the compiled version still retains the correct accde file
path does it not work, when simply the referenced database has been
recompiled again?
Is it programmatically possible to drop a reference (If it exists)
and add a reference, when a compiled version of Access boots up, such
as linking it to a macro named AutoExec?
Is there an alternative way to run the above code without having to
add it to an ‘Event’ for all form objects? Saving me time as I can
centralize the code in one place.
Any Ideas?
The simple and sad answer is that whenever your code and/or a reference is changed, the project has to be compiled.
So, when done, you have to distribute both the project accde file and its external files (those that are updated, in practice all) to the users.

MS Access automation

I need to run a MS Access job as an automated task. I know Access isn't really built for this type of task, but I have MOST of it working except for one, critical part. In short, this is what it's supposed to do:
Generate a PDF report for a user
Generate an email for the user
Attach the PDF to the email
Send the email via SMTP
It works if a user is logged into a desktop session. The process needs to run as an automated process, without requiring a user to be logged in. Using Powershell and the built-in Task Scheduler (Windows 7 Ultimate, 64-bit), I'm able to get it running on schedule. But the Access code fails when it tries to save the PDF. Through experimentation, I learned that I need to save to the "My Documents" folder, and I have the process running as "me", but I keep getting the same error message:
8/18/2014 4:00:17 PM Report Error in <method name>
2302
-1
0
<project name> can't save the output data to the file you've selected.
MTS
So I suspect that if I select the correct location to save the PDF, it will work. Is there a special location that the system and/or Task Scheduler (TS) can save to? Is there a special way to share a folder that it will allow TS to write to it (without requiring a user to be logged in)?
I personally usually save all these types of files/reports into the %TEMP% folder, which seems appropriate for this application since it is only to store it until it is emailed.
I haven't had any permission issues saving into this folder yet.
If you're unfamiliar with %TEMP% you can search for Environ variables and there are usually different useful file paths to common folders used by the system e.g. %APPDATA%,%USERPROFILE%` etc
Thanks for all the input. After exhaustive testing--based on the response from ashareef above--I've demonstrated that it can't be done. I tried saving to the following environment variable locations:
TEMP
APPDATA
LOCALAPPDATA
PUBLIC
USERPROFILE
I also tried:
C:\Users
C:\Temp
C:\Users\<my user name>\Documents
And none of those worked if I set the task to run whether I was logged in or not:
One location does work, but only if I'm logged in and I set the task to run only when I'm logged in:
C:\Users\<my user name>\Documents
To sum up:
Saving a file from Access
Running as a Scheduled Task
Whether you're logged in or not
Is not possible! So here at work, we're going with Plan B. Thanks for your help!