question

Amir-1400 avatar image
0 Votes"
Amir-1400 asked thedbguy answered

Check that if the linked table have a corresponding table in Sql Server

I have an Access program that is as FE and my database is SQL as BE. When I update and send my Access program to my clients, they get the updated version and copy it on their Pc. For the first time before logging in, they press a button that relinks the tables to database. The information of the connection string is in a table in their database. My code for relinking is quite simple but it has a bug. If all the tables in FE be present in BE there is no problem. But if there was a linked table in FE that doesn't be in BE, an error occurs and the relinking process fails.
How can I check that a table have a corresponding counterpart in BE and if it hasn't a corresponding table the code escapes it and continue to other tables?
And if the process was successful show a message.


 For Each td In db.TableDefs
   If td.Connect <> "" Then
     Set td = db.TableDefs(td.Name)
     td.Connect = strConnection
     td.RefreshLink
   End If
  Next
office-access-devoffice-deployment
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

thedbguy avatar image
0 Votes"
thedbguy answered

Hi. Not sure how that happens in your case. How can you have a table in your test/dev copy that is not in the live BE?

In any case, I think you could just simply catch the error and move on. Basically, ignore the table that is causing the error. You could also go as far as deleting it, if you really don't want it in the FE.

However, if you are using that non-existent table in any of your forms or code, how can the user use your application, if they don't have that table in their BE?

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.