A family of Microsoft relational database management systems designed for ease of use.
Had the same problem on my New Dell (which came with McAfee Antivirus) I was also having issues with adding tables and was getting the error message Cannot define field more than once. (Error 3191) which has nothing to do the actual issue, as there are no fields defined more than once.
This function works perfectly on my Windows 10 32 bit office Dell:
Function AttachDSNLessTable(stLocalTableName As String, stRemoteTableName As String, stServer As String, stDatabase As String, Optional stUsername As String, Optional stPassword As String)
On Error GoTo AttachDSNLessTable\_Err
Dim td As TableDef
Dim stConnect As String
For Each td In CurrentDb.TableDefs
If td.Name = stLocalTableName Then
CurrentDb.TableDefs.Delete stLocalTableName
DoEvents
End If
Next
stConnect = "ODBC;DRIVER=MySQL ODBC " & MySQLVersion & " ANSI Driver;SERVER=" & stServer & ";DATABASE=" & stDatabase & ";UID=" & stUsername & ";PWD=" & stPassword & ";Port=" & stPort & ";Option=8;Option=16"
End If
Set td = CurrentDb.CreateTableDef(stLocalTableName, dbAttachSavePWD, stRemoteTableName, stConnect)
DoEvents
**CurrentDb.TableDefs.Append td '64 bit MSAcces Ver 2202 build 14931.20120 click-to-run), Windows 11 errors out here**
AttachDSNLessTable = True
Exit Function
AttachDSNLessTable_Err:
AttachDSNLessTable = False
MsgBox "AttachDSNLessTable encountered an unexpected error: " & Err.Description & " " & stRemoteTableName
End Function
I was able to fix the Compact and Repair functionality by Uninstalling McAfee and Installing MalewareBytes instead. I was hoping this was going to resolve both issues, but I still can't add a table either with VBA above, or by trying to use the build in New Datasource wizard in MS Access. Thought I would mention both as they might be related.
Note: Just rebooted after getting rid of McAfee and compact and repair is still working, adding new linked tables is not however.