Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
| Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 15th, 2007, 10:03 AM
Authorized User
 
Join Date: Mar 2004
Location: , , USA.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default MS Access to SQL server connection

Hi,

I have an Access app split between front and and backend - and I've just upsized my Access backend to SQL server - and I've linked the tabled to my Access front end.

I'm a bit confused now - in my Access front end I have my original connection as follows:

SET db = ws.opendatabase("XXXX.mdb", False, False, "MS Access:PWD=")

Now that my data is on SQL Server how do I set db to point to SQL server. I refernce db throughout my code.

Thanks for any help,

Ian
 
Old February 16th, 2007, 08:36 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

It sounds like you were using DAO. DAO does not work with SQL Server. You will have to convert your code to ADO.

Are these tables linked or remote?

mmcdonal
 
Old February 16th, 2007, 11:11 AM
Authorized User
 
Join Date: Mar 2004
Location: , , USA.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, I'm using DAO - it's an app that's quite old - and the tables are linked.

 
Old February 16th, 2007, 01:59 PM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You will need to use ADO. If the tables are linked, it sounds like you are using a DSN. So you will need to make sure that the DSN is installed on each workstation.

Do this to talk to your local data with code (otherwise just make everything bound to tables and queries):

Dim rs As ADODB.Recordset
Dim sSQL As String

sSQL = "SELECT * FROM tblCustomers"

Set rs = New ADODB.Recordset
rs.Open sSQL, CurrentProject.Connection, adOpenDynamic, adLockOptimistic

This will allow you to do most of the work with the SQL tables.

HTH

mmcdonal




Similar Threads
Thread Thread Starter Forum Replies Last Post
MS ACCESS 2003 FRONTEND AND MS SQL SERVER 2005 DB mohankumar0709 SQL Server 2005 3 March 23rd, 2007 12:48 AM
can to link a ms access table to sql server? sugar SQL Server 2000 6 May 23rd, 2006 11:45 AM
how to convert ms access db to sql server method SQL Server 2000 1 March 11th, 2005 11:44 PM
No connection to sql server, Access and excel Dorenbos BOOK: ASP.NET Website Programming Problem-Design-Solution 1 March 22nd, 2004 12:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.