Converting Linked Tables......

Close that form and create a brand new form and try it.
 
Mike,,

I just tried this and it works fine ... Copy/Delete Link/Rename Table

Code:
Private Sub cmdCopyTable_Click()
Dim tdf As DAO.TableDef
Dim Temp As String

For Each tdf In CurrentDb.TableDefs
   If Len(tdf.Connect) > 0 Then
      Temp = tdf.Name
      DoCmd.RunSQL "Select * into [" & tdf.Name & "_New] From [" & tdf.Name & "]"
      DoCmd.RunSQL "Drop table [" & tdf.Name & "]"
      DoCmd.Rename Temp, acTable, Temp & "_New"
   End If
   Next
End Sub

Your error message indicates that your "code page" for your form has
code OUTSIDE of a module. Post the entire page if possible.

Wayne
 
Mike,

Also, the square brackets were added to the code so that it can handle the
inclusion of spaces in table names. but, you probably didn't do that anyway.

Wayne
 
This might have something to do with it. When I am in the form, I open the toolbox, I click the command button, I click onto the body of the form to insert the command button onto the form I get an error message:


Compile.error.in query expression 'AplLoadString([bw_tabBtnActions].Description)

The first time I built the form I just clicked OK and pasted the code into the button.
 
can you create a new .mdb and put the form (with it's module) in it and post it here to the forum?
 
OK, I created a new .MDB. Created a new form. Put the command botton on the form. In the "on click event" I typed in "=CopyTable_Click". A module named CopyTable_Click was created and the following code was inserted into the module:

Private Sub cmdCopyTable_Click()
Dim tdf As DAO.TableDef
Dim Temp As String

For Each tdf In CurrentDb.TableDefs
If Len(tdf.Connect) > 0 Then
Temp = tdf.Name
DoCmd.RunSQL "Select * into [" & tdf.Name & "_New] From [" & tdf.Name & "]"
DoCmd.RunSQL "Drop table [" & tdf.Name & "]"
DoCmd.Rename Temp, acTable, Temp & "_New"
End If
Next
End Sub

I get an error message of:

The expression OnClick you entered as the event property setting produced the following error: The expression you entered contains invalid syntax.
 
You should have [Event Procedure] in the on click event.

Delete what you have and put the cursor in the on click event area then a small button with ellipses (...) will appear on the right side. When you click this the code editor will appear. This is where you put the code...
 
I had to leave the client's site. I can only get the OBBC connection while I am there as they dont have a VPN, the access Db is on my machine, and access is not loaded on their server thus when I RDP in I cant connect via ODBC. Im going back there next week and will try again. Thanks for the time and help.
 
Mike,

Just inport the form in this database into your MDB with the linked tables
and press the command button.

Wayne
 

Attachments

Users who are viewing this thread

Back
Top Bottom