By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,773 Members | 2,583 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,773 IT Pros & Developers. It's quick & easy.

Recreate a deleted linked table

P: n/a
I upsized a database to SQL and accidentally deleted a table, how can
I recreate that linked table?
Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Row by painful row.

Unless of course you made a backup of your database before you upsided? Or
backed up the SQL code for the table (this would only allow you to recreate
the table and not restore the data)?

If you made a backup, you can just import the table.

"Lisa" <li******@yahoo.com> wrote in message
news:ef**************************@posting.google.c om...
I upsized a database to SQL and accidentally deleted a table, how can
I recreate that linked table?

Nov 12 '05 #2

P: n/a
"Lisa" <li******@yahoo.com> wrote in message
news:ef**************************@posting.google.c om...
I upsized a database to SQL and accidentally deleted a table, how can
I recreate that linked table?


Assuming this is an Access database with linked ODBC tables and you have
simply deleted the linked table from within Access - not the actual data.

File>Get External Data>Link Tables
Select Files of Type = ODBC
Then find your DSN, etc

Wasn't that how you originally created them?
Nov 12 '05 #3

P: n/a
I upsized the database to SQL using the upsizing wizard. So their seems
to be a DSN-less connection. So when you go to:
File> Get External Data....there is no DSN for the database. How do you
get around that?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #4

P: n/a
"Lisa Herrmann" <li******@yahoo.com> wrote in message
news:3f*********************@news.frii.net...
I upsized the database to SQL using the upsizing wizard. So their seems
to be a DSN-less connection. So when you go to:
File> Get External Data....there is no DSN for the database. How do you
get around that?

You could write a more generalised function, but if you simply need the
table re-linked, then create a form with a button on it named cmdLink and
paste the following code in the click event for the button. You just need
to replace 'MyServer', 'MyDatabase', etc with the appropriate values and
also decide whether you use a trusted connection or not. (In case you don't
already have it, you will have to set a reference to the DAO object library)
Private Sub cmdLink_Click()

On Error GoTo Err_Handler

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

strConnect = "ODBC;Driver={SQL Server};"
strConnect = strConnect & "Server=MyServer;"
strConnect = strConnect & "Database=MyDatabase;"
'Either this:
'strConnect = strConnect & "Trusted_Connection = Yes"
'Or this:
strConnect = strConnect & "UID=sa;"
strConnect = strConnect & "PWD=MyPassword;"

Set dbs = CurrentDb
Set tdf = dbs.CreateTableDef("tblMyTable")

tdf.Connect = strConnect

tdf.SourceTableName = "tblMyTable"

dbs.TableDefs.Append tdf

Exit_Handler:

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

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

Exit Sub

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

End Sub
HTH

Fletcher
Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.