AngelMiguel
New member
- Local time
- Today, 03:05
- Joined
- Nov 2, 2018
- Messages
- 11
I have had a serious problem with a commercial application for projects and accounting. In the end I have decided to leave aside their salesmen and programmers and access directly to the tables to get the data we need.
This is a test query with a simple table.
What I liked, due to my lack of experience, is that it works very well with the access forms in offline mode.
The next job is to modify, delete and add data.
I still have some initial work to do before I start working with several related tables.
Private Sub FullQuerySqlSage200c()
On Error GoTo FullQuerySqlSage200c_Error
Dim SUid As String
Dim Sclave As String
Dim Sdatabase As String
Dim Sserver As String
Dim cn As ADODB.Connection
Dim rscn As ADODB.Recordset
Dim frm As Access.Form
Dim AccessConnect As String
Set frm = Me.Form
SUid = "NameUser"
Sclave = "Pass"
Sdatabase = "NameDatabase"
Sserver = "NameServer"
strsql = ""
strsql = strsql & " SELECT LineasAlbaranProveedor.* " ' supplier delivery note lines
strsql = strsql & " FROM LineasAlbaranProveedor "
AccessConnect = "Driver=SQL Server;Uid=" & SUid & ";Pwd=" & Sclave & ";LANGUAGE=Español;Server=" & Sserver & ";Database=" & Sdatabase & ";Trusted_Connection=No"
Set cn = New ADODB.Connection
With cn
cn.ConnectionString = AccessConnect
cn.Open
End With
Set rscn = New ADODB.Recordset
With rscn
Set rscn.ActiveConnection = cn
rscn.Source = strsql
rscn.LockType = adLockOptimistic
rscn.CursorType = adOpenStatic
rscn.CursorLocation = adUseClient
rscn.Open
Set frm.Recordset = rscn
frm.Refresh
End With
Set rscn = Nothing
Set cn = Nothing
Set frm = Nothing
strsql = ""
On Error GoTo 0
Exit Sub
FullQuerySqlSage200c_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure FullQuerySqlSage200c, line " & Erl & "."
End Sub
This is a test query with a simple table.
What I liked, due to my lack of experience, is that it works very well with the access forms in offline mode.
The next job is to modify, delete and add data.
I still have some initial work to do before I start working with several related tables.
Private Sub FullQuerySqlSage200c()
On Error GoTo FullQuerySqlSage200c_Error
Dim SUid As String
Dim Sclave As String
Dim Sdatabase As String
Dim Sserver As String
Dim cn As ADODB.Connection
Dim rscn As ADODB.Recordset
Dim frm As Access.Form
Dim AccessConnect As String
Set frm = Me.Form
SUid = "NameUser"
Sclave = "Pass"
Sdatabase = "NameDatabase"
Sserver = "NameServer"
strsql = ""
strsql = strsql & " SELECT LineasAlbaranProveedor.* " ' supplier delivery note lines
strsql = strsql & " FROM LineasAlbaranProveedor "
AccessConnect = "Driver=SQL Server;Uid=" & SUid & ";Pwd=" & Sclave & ";LANGUAGE=Español;Server=" & Sserver & ";Database=" & Sdatabase & ";Trusted_Connection=No"
Set cn = New ADODB.Connection
With cn
cn.ConnectionString = AccessConnect
cn.Open
End With
Set rscn = New ADODB.Recordset
With rscn
Set rscn.ActiveConnection = cn
rscn.Source = strsql
rscn.LockType = adLockOptimistic
rscn.CursorType = adOpenStatic
rscn.CursorLocation = adUseClient
rscn.Open
Set frm.Recordset = rscn
frm.Refresh
End With
Set rscn = Nothing
Set cn = Nothing
Set frm = Nothing
strsql = ""
On Error GoTo 0
Exit Sub
FullQuerySqlSage200c_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure FullQuerySqlSage200c, line " & Erl & "."
End Sub
Last edited: