Query full dates in Server SQL , Sage 200c, Form offline (1 Viewer)

AngelMiguel

New member
Local time
Today, 12:55
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
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 12:55
Joined
Oct 29, 2018
Messages
21,454
Hi. Is there a question in there somewhere?
 

jdraw

Super Moderator
Staff member
Local time
Today, 15:55
Joined
Jan 23, 2006
Messages
15,379
Angel,

Would you like to edit your post and tell us what the code solves/its purpose and enclose the code in code tags for readability? Telling users the purpose will facilitate communications.
Highlight the code, then click the </> character to wrap the vba in ode tags.
 

AngelMiguel

New member
Local time
Today, 12:55
Joined
Nov 2, 2018
Messages
11
Sorry for the response in the exhibition. I lack experience in ADODB.Connection.
Could you please indicate if this code is correct, or would you add something else?
I have tested that the code works, but I have doubts about the construction.
Thanks and apologies.
theDBguy sorry
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 05:55
Joined
Jan 20, 2009
Messages
12,851
Why you are doing it this way rather than with linked tables and forms bound to queries on those tables?
 

Users who are viewing this thread

Top Bottom