Error Running MS Access Macro from Task Scheduler

Question and solution here: https://superuser.com/questions/402070/run-task-scheduler-task-on-demand-from-limited-user-account-in-windows-7

Go to C:\Windows\System32\Tasks find the related task and assign "read and execute" rights to the user you want to be able to access it. Be sure to assign to "current object only." Then the task will be visible and runnable from the limited user, and it will work if you saved your credentials in it and checked "run whether user is logged on or not."

Constant MS Access database corruption

From here: https://support.microsoft.com/en-gb/help/2957623/cannot-access-shared-files-or-folders-on-a-drive-in-windows-server-201

Symptoms


You may experience one of the following issues:
  • You can see the shared files but cannot open them.
  • When you open a shared file, the loading progress bar is displayed as zero percent.
  • When you open a shared file or a folder, Windows explorer freezes.
  • If you try to restart the Server service, the service freezes in the stopping state.
  • Microsoft Office Access databases (.mdb files) that are hosted on Windows Server 2012 shares may be corrupted.
  • A "file is locked by another user" or "is locked for editing" error occurs in Microsoft Excel.
  • SMB2 dialect negotiation receives only a TCP ACK response.

To work around these issues, follow these steps:

  1. Disable the leasing on the file server. To do this, run the following command:
    REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters /v DisableLeasing /t REG_DWORD /d 1 /f 
    Note After you set this registry key, SMB2 leases are no longer granted, but oplocks are still available. This setting is primarily used for troubleshooting.
  2. Restart the file server, or restart the server service. To restart the service, run the following commands:
    NET STOP SERVER
    NET START SERVER

  

MS Access ADODB method

  1. Dim cn As New ADODB.Connection
  2. Dim rs As ADODB.Recordset
  3. Dim strSQL As String
  4.  
  5. strSQL = "Select * from Employees ORDER BY [LastName],[FirstName];"
  6.  
  7. Set rs = New ADODB.Recordset
  8.  
  9. With rs
  10.   .Source = strSQL
  11.   .ActiveConnection = CurrentProject.Connection
  12.   .CursorType = adOpenDynamic
  13.   .LockType = adLockOptimistic
  14.     .Open
  15.  
  16.    Do While Not .EOF
  17.      Debug.Print UCase$(![LastName]) & ", " & ![FirstName]
  18.        .MoveNext
  19.    Loop
  20. End With
  21.  
  22. rs.Close
  23. Set rs = Nothing

 

Undefined function 'Nz' in expression

You SHOULD replace the Nz with an IIf(IsNull()) construct as it's prone to Errors for NOT reason.

See documentation for IIf and IsNull

When put together:Nz(expr, [valueifnull])
becomesIIf(IsNull(expr), valueifnull, valueifnotnull)

Examples
Default: Nz(tbl.A) => IIf(IsNull(tbl.A), '', tbl.A)
With fallback: Nz(tbl.A, tbl.B) => IIf(IsNull(tbl.A), tbl.B, tbl.A)

MS Access to SQL Upgrade Check List

These are som items that need to be considered/done when upgrading from MS Access backend to SQL Server backend.

1. Replace # with single quote (') for Dates in SQL.
2. Add Timestamp to all SQL tables.
3. Add dbSeeChanges to all DAO CurrentDB.Execute SQL statements. dbFailOnError should become dbSeeChanges + dbFailOnError
4. Convert all MulitValue fields to flat fields. This usually like multi-select combo baoxes that have to be converted to Listboxes.
5. Convert all Attachment Fields to VarBinary subTables!

MS Access Database Check Box List Filters Missing On SQL Server back end

If you convert your MS Access backend to SQL Server backend you will lose the datagrid/datasheet filter dropdown list.

To get it back you need to go to File-Options-Current Database. Under the Filter Look Up you will see ODBC Fields. Just check that box, close and open the app. Then it's available.

One point to watch for is that if the data is read-only, it will not filter.

VBA win-7 64 bit error (run-time error 429 activex component can't create object)

You created a DLL in Visual Studio 2010 so you can reference it in MS Access VBA.

It works fine in 32-bit Office but you get an error (error 429 activex component can't create object) when trying to run in 64-bit Office.

Solution: Unfortunatley non built-in ActiveX objects cannot be created in 64-bit Office and there is no direct work around for this.

VBA Compile Error: Procedure Too Long

I ran into a very strange error recently when I took over someone elses MS Access project. The so called developer did not use Option Explicit anywhere in the code so I added it into all modules and fixed all the misspelled variables and missing variables. Then the final Error I got when compiling was "Procedure Too Long"! That was odd as the routine in question was maybe 1000 lines long so it was NOT too long at all. After reviewing the code in more detail I decided to change some of the massive If-Then-Else blocks into Case Statements and just like magic, after the first one, I was able to get past this stupid error.

There must be some sort of limitation on the number of If-Else statements in VBA routines.