如果这样的东西已经发布或者只是一个简单的修复,我很抱歉,但我一直在四处寻找,似乎无法找到解决这个问题的方法。我正在使用 vba: ms 访问,并且我试图通过运行查询来比较不同数据库中的两个相同的表。我一直在尝试制作脚本,以便它可以在只需要用户输入的不同数据库上运行。然而,通过这个过程,我似乎不断收到一个错误,内容如下:
select 语句包含拼写错误或丢失的保留字或参数名称。
LinkUserTable 函数基本上根据用户输入从另一个数据库创建链接表。下面是子程序:
Sub LinkTables()
Dim sTable1 As String
Dim sTable2 As String
sTable1 = LinkUserTable
sTable2 = LinkUserTable
vars_sql = "SELECT " & sTable1 & ".[f_ptid]," & sTable1 & ".[f_flag]," & sTable1 & ".[f_user]," & sTable1 & ".[f_brief]," & sTable1 & ".[f_gid]," & sTable1 & ".[f_vco]," & sTable1 & ".[f_dtype]," & sTable1 & ".[f_precs]," & sTable1 & ".[f_addr]," & sTable1 & ".[f_ndim]," & sTable1 & ".[f_sys]," & sTable1 & ".[f_unit]," & sTable1 & ".[f_value]," & sTable1 & ".[f_pred]," & sTable1 & ".[f_bflag]," & sTable1 & ".[f_dim1]," & sTable1 & ".[f_dim2]," & sTable1 & ".[f_dim3]," & sTable1 & ".[f_bound]," & sTable1 & ".[f_size]," & sTable1 & ".[f_updat]," & sTable1 & ".[f_time]," & sTable1 & ".[f_ldes]," & sTable1 & ".[f_sflag]," & sTable1 & ".[f_tflag]," & sTable1 & ".[rid]" + _
"FROM" + sTable1 + " AS LEFT JOIN " + sTable2 + " AS ON sTable1.[f_ptid] = sTable2.[f_ptid]" + _
"WHERE (((" & sTable2 & ".[f_ptid]) Is Null))"
If CheckQuery("new_old") = "Yes" Then
DoCmd.DeleteObject acQuery, "new_old"
End If
Set qdf = CurrentDb.CreateQueryDef("new_old", vars_sql)
End Sub
我只是想知道基于此可能会导致此错误的问题是什么?所有字段都在两个数据库中,都具有相同的属性(只是不同的数据)。如果缺少信息,我深表歉意,如果需要,我可以提供更多信息。