Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Creating a DSN-less, updatable SQL Server linked table in Access 2007

Posted on 2012-12-21
8
Medium Priority
?
1,316 Views
Last Modified: 2012-12-22
In Access 2007, I've created a DSN-less connection to a SQL Server 2008 R2 table, to create a linked table which I've dropped into an Access form. I followed this MS link:

http://support.microsoft.com/kb/892490

In VBA, I used the Form_Open event to call "AttachDSNLessTable" as outline in the KB article.

Q1: I see "Recordset is not updateable", and it won't let me edit the recordset. I'm assuming it doesn't maintain connection to the SQL table. How do I change this so I can add/edit/delete records in this linked table (and thus have them automatically propogate to the SQL table)?

Q2: From VBA, I'd like to be able to update this linked table in certain spots in a procedure. How do I do so?

I suspect these 2 questions are related. Thanks.
0
Comment
Question by:jdallen75
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 52

Expert Comment

by:Gustav Brock
ID: 38714524
Q1: You probably missed to add a Timestamp field in the SQL Server table and relink it.

Q2: Like any other recordset using DAO.

/gustav
0
 

Author Comment

by:jdallen75
ID: 38714599
There is a timestamp field, but the records are not necessarily unique on that field (it's an "edited" field). How does that affect this?

I'm using ADO currently... How does this differ from DAO in this case?
0
 
LVL 48

Expert Comment

by:Dale Fye
ID: 38714609
You will also need a primary key in the table in order to edit it from Access.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:jdallen75
ID: 38714617
Thanks, fyed. That's probably it ... I didn't create the table :-P
0
 

Author Comment

by:jdallen75
ID: 38715839
I found the problem: Access can't handle bigint datatypes, which is what the primary key was identified with.

That takes care of Q1.

I'm still having an issue with Q2: namely, I'd like to be able to update the linked table (the same as going through the Linked Table Manager, selecting the linked table, and updating manually), but through VBA code. I've come across dozens of blogs and nothing seems to update.

I'd like this so if Access has been open for some time, the user can click a Refresh button to ensure that what they see on screen is true to the SQL table.
0
 
LVL 52

Expert Comment

by:Gustav Brock
ID: 38715874
For that you only need to requery the recordset of the form the user is watching.

Relinking is only needed when schema changes (adding/modifying fields etc.) have taken place.

/gustav
0
 

Author Comment

by:jdallen75
ID: 38716046
Gustav,

Any idea what that syntax would look like? I ask because I tried a few methods, one of which used a ".RefreshLink" or ".Refresh"(?) and the table didn't update when an underlying record change had happened.
0
 
LVL 52

Accepted Solution

by:
Gustav Brock earned 1050 total points
ID: 38716054
It is method Requery.

Method RefreshLink is for refreshing linked tables when the connection string has changed.

/gustav
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question