ahmedjamalaboelez
Ahmed J. Aboelez
- Local time
- Today, 02:32
- Joined
- Feb 25, 2015
- Messages
- 79
Good Day Access World,
I use following code to bring data from SqlServer table to access table with same structure columns inside , because I do not like to involve with Passthrough Queries, or record set control, it works fine with me bit

I have two question :

1 - is the following Sql Command fast as passthrough Query , or another way to make TableDef , or QueryDef. ( is it hit directly SqlServer database or not).
2 - How Could I Add Some Criteria to following Sql Command , I want to add Where AccountID = " & StrCriteria & " .
Thanks In Advance ,
A.J
I use following code to bring data from SqlServer table to access table with same structure columns inside , because I do not like to involve with Passthrough Queries, or record set control, it works fine with me bit


I have two question :


1 - is the following Sql Command fast as passthrough Query , or another way to make TableDef , or QueryDef. ( is it hit directly SqlServer database or not).
2 - How Could I Add Some Criteria to following Sql Command , I want to add Where AccountID = " & StrCriteria & " .
Code:
CurrentDb.Execute "INSERT INTO " & strLocalTable & " SELECT * FROM [ODBC;Description=Test;DRIVER=SQL Server;SERVER=" & strServer & ";UID=" & strUser & ";PWD=" & strPass & ";DATABASE=" & strDatabase & "]." & strServerTable & ";"
Code:
Dim strServer As String
Dim strDatabase As String
Dim strUser As String
Dim strPass As String
strServer = "192.168.1.194"
strDatabase = "EasyCount"
strUser = "sa"
strPass = "@MyPass"
Dim strLocalTable As String
Dim strServerTable As String
strLocalTable = "lc_account_sql"
strServerTable = "A02AccountsMaster"
CurrentDb.Execute "INSERT INTO " & strLocalTable & " SELECT * FROM [ODBC;Description=Test;DRIVER=SQL Server;SERVER=" & strServer & ";UID=" & strUser & ";PWD=" & strPass & ";DATABASE=" & strDatabase & "]." & strServerTable & ";"
Thanks In Advance ,
A.J