Creating runtime version

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

I have a database, the back end is in SQL server and the front-end (forms,
Query's mudules) is in Access.

I will be distributing this to my client who will keep the tables in SQL
Server and I am trying to set up access into a runtime version. The
machines that will be running this application do not have MS access
installed. I will need the runtime version to point to the tables in SQL.

I've never done this before, so speaking in dummy language is perfectly
acceptable. Any advice or just point me in the right direction will be
fantastic!

Thanks alot.
 
Chris said:
I have a database, the back end is in SQL server and the front-end (forms,
Query's mudules) is in Access.

I will be distributing this to my client who will keep the tables in SQL
Server and I am trying to set up access into a runtime version. The
machines that will be running this application do not have MS access
installed. I will need the runtime version to point to the tables in
SQL.

I've never done this before, so speaking in dummy language is perfectly
acceptable. Any advice or just point me in the right direction will be
fantastic!

Thanks alot.


If you are intending to hand this over to a client, then I guess you are
going to want to test things first. You should be running some form of SQL
Server yourself (perhaps a developer version or a free MSDE installation).
You cannot properly test out the application without this.
The next thing to establish is how you are going to use Access in
conjunction with SQL Server - I guess from your post that you intend to use
an mdb or mde format with linked odbc tables. This is perhaps the most
common option but not the only one.
Assuming linked odbc tables, then you generally write code for your runtime
Access application to link to the SQL Server, but there are still further
questions to answer. Which security model does the SQL Server use, it will
be either via SQL Server or Windows authentication. If the client is using
Windows-only authentication, then this is probably easier for you as a
developer, since you don't have to worry about user names and passwords.
However, if SQL Server authentication is used, you now need to think about
how to ensure your application should work without compromising security (eg
should you save a user id and password with the linked tables).
Once you have those two points figured out, there is plenty of code around
to re-link tables from your demo database to the client's real one. Just
post back if you need more.
 
Justin Hoffman said:


Hi Justin, and thanks for answering my post.
If you are intending to hand this over to a client, then I guess you are
going to want to test things first. You should be running some form of SQL
Server yourself (perhaps a developer version or a free MSDE installation).
You cannot properly test out the application without this.

I've got the tables in SQL Server and my testing is complete
The next thing to establish is how you are going to use Access in
conjunction with SQL Server - I guess from your post that you intend to use
an mdb or mde format with linked odbc tables. This is perhaps the most
common option but not the only one.

I developed the application in access then upsized it to SQL Server. I'm
not sure as of yet whether to use mdb or mde, but I'm pretty sure I'll be
using linked ODBC tables
Assuming linked odbc tables, then you generally write code for your runtime
Access application to link to the SQL Server,

This is where I'm stuck. I don't know how to turn access into a runtime
version and I don't know how to write the code to link to the runtime
version with SQL server.
but there are still further questions to answer. Which security model
does the SQL Server use, it will

Windows Authentication
Once you have those two points figured out, there is plenty of code around
to re-link tables from your demo database to the client's real one. Just
post back if you need more.

I'm looking but I can't find any
 
Chris said:
Hi Justin, and thanks for answering my post.


I've got the tables in SQL Server and my testing is complete


I developed the application in access then upsized it to SQL Server. I'm
not sure as of yet whether to use mdb or mde, but I'm pretty sure I'll be
using linked ODBC tables


This is where I'm stuck. I don't know how to turn access into a runtime
version and I don't know how to write the code to link to the runtime
version with SQL server.

does the SQL Server use, it will

Windows Authentication


I'm looking but I can't find any



Hi Chris
In order to create a runtime version, you need to have the Developer Edition
of MS Office (2000 and XP) which I believe you now purchase as 'Office
Developer Extensions' for Access 2003. Anyway, if you just have, say Office
Pro which comes with Access, there is no way to create an Access runtime
setup.
There is a lot that could be said about runtime installations, but there are
some downsides to installing Access like this (otherwise no-one would buy
the full product). These include requiring all errors to be properly
handled, no built-in tollbars or menus, no query by form and the list goes
on. If you have not tested your application as a runtime installation, then
you are not yet finished testing. You can simulate the runtime environment
by creating a shortcut to your database and specifying the runtime
parameter, e.g.
"C:\Program Files\Microsoft Office\Office10\MSACCESS.EXE"
"C:\MyDatabase.mdb" /RUNTIME
If this all sounds a bit daunting, is there any way the client would buy a
full version of Access? Otherwise you may need to buy another version
(unless you already have the Developer Edition).

Anyway, if you need to re-link the tables, you could paste the following
code into a new module and just call the function ReLinkTables. In this
version, you create a list of tables you want to link to, specifying what
they are called on the server and how you want to call them (and here we
have just chopped off the dbo prefix)


Public Function ReLinkTables() As Boolean

On Error GoTo Err_Handler

Dim strConnect As String
Dim strTableList As String

strConnect = "ODBC;Driver={SQL Server};" & _
"Server=MyServer;" & _
"Database=MyDatabase;" & _
"Trusted_Connection=yes;"

' Table list is in pairs like "SQL_Server|Link_Table;"
strTableList = "dbo.Customer|tblCustomers;" & _
"dbo.Product|tblProducts;" & _
"dbo.Order|tblOrders"

If DeleteLinks(strTableList) Then
If LinkTables(strTableList, strConnect) Then
ReLinkTables = True
End If
End If

Exit_Handler:
Exit Function

Err_Handler:
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler

End Function


Private Function LinkTables(strTableList As String, strConnect As String) As
Boolean

On Error GoTo Err_Handler

Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Dim astrTables() As String
Dim strTwoTables As String
Dim strSqlServerTable As String
Dim strLinkTable As String
Dim lngPosition As Long
Dim lngCount As Long

Set dbs = CurrentDb

astrTables = Split(strTableList, ";")

For lngCount = 0 To UBound(astrTables())

strTwoTables = astrTables(lngCount)

lngPosition = InStr(strTwoTables, "|")

If (lngPosition > 0) And (Len(strTwoTables) > lngPosition) Then

strSqlServerTable = Mid$(strTwoTables, 1, lngPosition - 1)

strLinkTable = Mid$(strTwoTables, lngPosition + 1)

Set tdf = dbs.CreateTableDef(strLinkTable)

tdf.Connect = strConnect

tdf.SourceTableName = strSqlServerTable

dbs.TableDefs.Append tdf

Set tdf = Nothing

End If

Next lngCount

LinkTables = True

Exit_Handler:

On Error Resume Next

If Not tdf Is Nothing Then
Set tdf = Nothing
End If

If Not tdf Is Nothing Then
Set dbs = Nothing
End If

Application.RefreshDatabaseWindow

Exit Function

Err_Handler:
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler

End Function


Private Function DeleteLinks(strTableList As String) As Boolean

On Error GoTo Err_Handler

Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Dim astrTables() As String
Dim strTwoTables As String
Dim strLinkTable As String
Dim lngPosition As Long
Dim lngCount As Long
Dim blnError As Boolean

Set dbs = CurrentDb

astrTables = Split(strTableList, ";")

For lngCount = 0 To UBound(astrTables())

strTwoTables = astrTables(lngCount)

lngPosition = InStr(strTwoTables, "|")

If (lngPosition > 0) And (Len(strTwoTables) > lngPosition) Then

strLinkTable = Mid$(strTwoTables, lngPosition + 1)

If TableExists(strLinkTable) Then

Set tdf = dbs.TableDefs(strLinkTable)

If Len(tdf.Connect) > 0 Then
dbs.TableDefs.Delete tdf.Name
Else
' This is not a linked table
MsgBox "Cannot delete table '" & strLinkTable & "'",
vbExclamation
blnError = True
End If

Set tdf = Nothing

End If

End If

Next lngCount

If Not blnError Then
DeleteLinks = True
End If

Exit_Handler:

On Error Resume Next

dbs.TableDefs.Refresh

If Not dbs Is Nothing Then
Set dbs = Nothing
End If

Application.RefreshDatabaseWindow

Exit Function

Err_Handler:
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler

End Function

Private Function TableExists(strTableName As String) As Boolean

On Error GoTo Err_Handler

Dim dbs As DAO.Database
Dim tdf As DAO.TableDef

Set dbs = CurrentDb

For Each tdf In dbs.TableDefs
If tdf.Name = strTableName Then
TableExists = True
Exit For
End If
Next tdf

Exit_Handler:

On Error Resume Next

If Not dbs Is Nothing Then
Set dbs = Nothing
End If

Exit Function

Err_Handler:
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler

End Function
 
Back
Top