Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
CREATE VIEW myview AS
[i]paste the access query here[/i]
Private Function MyTestFunction()
Dim i
Dim qd As DAO.QueryDef
Dim dbcnn As ADODB.Connection
Const cnProvider As String = "MSDataShape" '"SQLOLEDB"
Const cnNetwork As String = "DBMSSOCN" 'Use TCP/IP
Const cnSecurity As String = "SSPI"
Const cnSrvName As String = "*** YOUR SERVER NAME ***"
Const cnTimeout As Integer = 600
Dim cnDBName As String
cnDBName = "*** YOUR DATABASE NAME ***"
With dbcnn
.Provider = cnProvider
.ConnectionString = "DATA PROVIDER=SQLOLEDB; Network Library=DBMSSOCN"
.CommandTimeout = cnTimeout
.Properties("Data Source") = cnSrvName
.Properties("Initial Catalog") = cnDBName
.Properties("Integrated Security") = cnSecurity
'.Properties("Network Library") = cnNetwork
.Open
End With
For i = 0 To CurrentDb.QueryDefs.Count - 1
Set qd = CurrentDb.QueryDefs(i)
Dim strSQL As String
strSQL = "SET NO COUNT ON "
strSQL = strSQL & "if exists (select * from dbo.sysobjects where id = object_id(N'[dbo]." & qd.Name & "') and OBJECTPROPERTY(id, N'IsView') = 1)" & vbCrLf
strSQL = strSQL & "drop view [dbo]." & qd.Name
dbcnn.Execute strSQL
dbcnn.Execute ("CREATE VIEW DBO." & qd.Name & " AS " & qd.SQL)
Next i
End Function
strSQL = "SET NO COUNT ON "
strSQL = strSQL & "if NOT exists (select * from dbo.sysobjects where id = object_id(N'[dbo]." & qd.Name & "') and OBJECTPROPERTY(id, N'IsView') = 1)" & vbCrLf
dbcnn.Execute (strSQL & " GO " & "CREATE VIEW DBO." & qd.Name & " AS " & qd.SQL)