Share via

vba Set openRecordSet Linked SQL table

Anonymous
2013-04-25T14:17:25+00:00

I have written some code in access 2013 to open the Global Address List in outlook and when I select names it uploads the information to my table in access. It works when using a table in Access but when I switch to a Linked sql table the Set rst = CurrentDb.OpenRecordset("Employees") gives me a error. I am assuming because it is a Linked SQL table.

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

4 answers

Sort by: Most helpful
  1. Anonymous
    2013-04-26T14:16:23+00:00

    I tried again and it worked. The only thing I can figure out is if the table is open it won't work but if I close the table it works. Guess I will need to run a test to see if is open then close it before the

    Set rst = CurrentDb.OpenRecordset("Employees") command.

    Was this answer helpful?

    0 comments No comments
  2. Tom van Stiphout 40,211 Reputation points MVP Volunteer Moderator
    2013-04-26T04:16:56+00:00

    Still you're not giving us (and the wider community finding your issue later, and looking for a solution) the verbatim error message :-(

    Your code:

    Set rst = CurrentDb.OpenRecordset("Employees")

    will work. I am assuming Employees is a linked SQL Server table.

    As you probably know, your line is equivalent to:

    Set rst = CurrentDb.OpenRecordset("Employees", dbOpenDynaset)

    I prefer that, because it is more explicit that you intend to edit data in this recordset, not just read it.

    Did you re-link the table using the Linked Table Manager?

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2013-04-25T18:57:55+00:00

    No I have a primary key that's not it. I worked around it just edited the form I am on it works fine now. but would like to know how to open a record set for a linked SQL table which I will need to know how to do still for some other task.

    Was this answer helpful?

    0 comments No comments
  4. Tom van Stiphout 40,211 Reputation points MVP Volunteer Moderator
    2013-04-25T14:24:38+00:00

    Please quote error messages verbatim.

    Perhaps you don't have a Primary Key in your SQL table?

    Was this answer helpful?

    0 comments No comments