Private Sub Form_Load() On Error GoTo ae DoCmd.TransferDatabase acLink, "ODBC", "ODBC;DRIVER=SQL Server;SERVER=SERVER/yde;UID=sa;PWD=a123;DATABASE=daad", acTable, "", "", True ae: Exit Function End Sub
说明: "SERVER/yde" 为SQL服务器 sa SQL连接用户名 a123 SQL连接密码 daad 所要连联的数据库