|
我在SQL中建了一些视图,在access通过VBA重链接表时,系统会跳出选择唯一的记录标识符的窗体让手工选择,请问能不能通过代码自动选择第一个,我的重链接代码如下(因为有些表的特殊性,所以视图无法建索引视图):- Dim i As Integer
- Dim j As String
- Dim k As Integer
- k = DFirst("[A001_ZJLX]", "A_AA_A006")
- For i = 1 To k
- j = DLookup("BM", "A_AA_A001", "BMNO =" & i)
- On Error GoTo fb:
- DoCmd.DeleteObject acTable, j
- On Error GoTo fb:
- fb:
- DoCmd.TransferDatabase acLink, "ODBC", _
- "ODBC;DRIVER=SQL Server;SERVER=" & E_Co_ServerIP & ";UID=" & E_Co_user & ";PWD=" & E_Co_password & ";LANGUAGE=us_english;" & "DATABASE=" & E_Co_KM & "", acTable, j, j, True
- Next i
- MsgBox "数据表更新成功,系统将进入登录画面!", vbInformation + vbOKOnly, Erp_提示
- DoCmd.OpenForm "C_AA_Login"
- 'DoCmd.Close acForm, Me.Name
-
- On Error GoTo Err_CmdLink_Click_Click
- Exit_CmdLink_Click_Click:
- Exit Sub
- Err_CmdLink_Click_Click:
- MsgBox Err.Description
- Resume Exit_CmdLink_Click_Click
复制代码 |
|