I don't get that issue Tom, I changed the alias and the table got recreated correctly with the new name. We are dropping the tables, here is the code:
Code:
Public Sub CreateQuery(sQueryName As String, sQuerySQL As String)
Dim qdf As DAO.QueryDef, qdfMk As DAO.QueryDef
On Error Resume Next
DoCmd.DeleteObject acQuery, sQueryName
DoCmd.DeleteObject acTable, Replace(sQueryName, "qry", "tbl") 'delete existing table first
Set qdf = CurrentDb.CreateQueryDef(sQueryName, sQuerySQL)
'SELECT qryDemographics.* INTO tblDemographics FROM qryDemographics;
If Forms![F01_MainMenu].chkCreateMK = True Then 'STEP 3
Set qdfMk = CurrentDb.CreateQueryDef("mk_" & sQueryName, "SELECT [" & sQueryName & "].* INTO " & Replace(sQueryName, "qry", "tbl") & " FROM [" & sQueryName & "];")
End If
If Forms![F01_MainMenu].chkExecuteMK = True Then 'STEP 4
CurrentDb.Execute "mk_" & sQueryName, dbFailOnError
End If
CurrentDb.QueryDefs.Refresh
Application.RefreshDatabaseWindow
iCounter = iCounter + 1 'increment public table counter
End Sub