Current I have created two databases in MS. Access and SQL Server with everything similar that is same tables no differences whatsoever. Now because we are now required to use SQL Server as the group database which means that all the 70 branches must use the internet permanently to remain connected. Due to poor connectivity in some branches located in the rural areas there is need to store data in Ms Access temporarily and then link back to SQL server when the connectivity is stable. Do not worry about how to shift the stored data in access database to SQL Server, I have a solution on that one, the problem here is how to create an option to connect either to access database or SQL Server with VBA that is where my puzzle is.
The access database here is used to store sales data only and then transfer that data to sql server as mentioned above.
(1) Is there a way to create an option to allow users to connect either to SQL Server OR Access database, example currently we are using this VBA below to SQL Server
(2) Is it possible to store the SQL tables connection strings in a table so that the Access linked strings to the Access database remain undisturbed. But again, how do I now use VBA to use the stored SQL Server string in a local table to connect back to SQL Server.
The access database here is used to store sales data only and then transfer that data to sql server as mentioned above.
(1) Is there a way to create an option to allow users to connect either to SQL Server OR Access database, example currently we are using this VBA below to SQL Server
Code:
Private Sub Form_Open(Cancel As Integer)
Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Set dbs = CurrentDb
For Each tdf In dbs.TableDefs
If Len(tdf.Connect) > 0 Then
tdf.Connect = "ODBC;DRIVER=SQL Server; " & _
"SERVER=NECTORPRIME\SQLExpress;DATABASE=Accounting;Trusted_Connection=Yes"
tdf.RefreshLink
End If
Next tdf
Set tdf = Nothing
Set dbs = Nothing
If (Date > #12/31/2022#) Then
MsgBox "Your database has expired contact the developer." & vbCrLf & "Please contact us at our official email address" & vbCrLf & "or at 260977352401 for the latest version.", vbInformation + vbOKOnly, "Subscription Expired!"
Cancel = True
Application.Quit
Exit Sub
End If
End Sub
(2) Is it possible to store the SQL tables connection strings in a table so that the Access linked strings to the Access database remain undisturbed. But again, how do I now use VBA to use the stored SQL Server string in a local table to connect back to SQL Server.