Etxezarreta
Member
- Local time
- Today, 19:16
- Joined
- Apr 13, 2020
- Messages
- 175
Hi,
I need to update the connections of my VBA code, in order to rebuild the link between Access FE and SqlServerBE.
To do so I create public variables, and there values are assigned when Access opens (more precisely on the load event of the presentation form) (see section A at the bottom of the message).
My question is: what would be the correct way to get rid of "CurrentProject.AccessConnection" and to update expressions such as "Set objConnection = CurrentProject.AccessConnection" used for instance to create recordsets like in
" With objRcdset_Source_Projet
.Source = str_SQL_ProjetAffecte
.ActiveConnection = objConnection"
or to run queries like in "objConnection.Execute (str_SQL)"
Thank you!
Etxe.
***SectionA***************************************
Public str_pub_StringDeConnection As String
Public str_pub_Server As String
Public str_pub_Database As String
Public obj_pub_ConnectionSqlServer As New ADODB.Connection
Private Sub Form_Load()
str_pub_Server = "DESKTOP-5D648IQ\SQLEXPRESS"
str_pub_Database = "EssaiMigration11052020"
str_pub_StringDeConnection = "Provider=SQLNCLI11;Data Source=" & str_pub_Server & ";Initial Catalog=" & str_pub_Database & ";Integrated Security=SSPI;"
Set obj_pub_ConnectionSqlServer = New ADODB.Connection
obj_pub_ConnectionSqlServer.Open str_pub_StringDeConnection
DoCmd.OpenForm "af_aMenu", acNormal
End Sub
******************************************************************************************
I need to update the connections of my VBA code, in order to rebuild the link between Access FE and SqlServerBE.
To do so I create public variables, and there values are assigned when Access opens (more precisely on the load event of the presentation form) (see section A at the bottom of the message).
My question is: what would be the correct way to get rid of "CurrentProject.AccessConnection" and to update expressions such as "Set objConnection = CurrentProject.AccessConnection" used for instance to create recordsets like in
" With objRcdset_Source_Projet
.Source = str_SQL_ProjetAffecte
.ActiveConnection = objConnection"
or to run queries like in "objConnection.Execute (str_SQL)"
Thank you!
Etxe.
***SectionA***************************************
Public str_pub_StringDeConnection As String
Public str_pub_Server As String
Public str_pub_Database As String
Public obj_pub_ConnectionSqlServer As New ADODB.Connection
Private Sub Form_Load()
str_pub_Server = "DESKTOP-5D648IQ\SQLEXPRESS"
str_pub_Database = "EssaiMigration11052020"
str_pub_StringDeConnection = "Provider=SQLNCLI11;Data Source=" & str_pub_Server & ";Initial Catalog=" & str_pub_Database & ";Integrated Security=SSPI;"
Set obj_pub_ConnectionSqlServer = New ADODB.Connection
obj_pub_ConnectionSqlServer.Open str_pub_StringDeConnection
DoCmd.OpenForm "af_aMenu", acNormal
End Sub
******************************************************************************************