If tabel exists

M

Martin

Hello,

I have some code that checks if a table exists and if it doesn't then
reattach the linked table. However it doesn't work as it just attaches the
table anyway.

Can anyone help?

If TableList = DCount("[Name]", "MSysObjects", "[Name] = 'tbl Clients'") =
False Then DoCmd.TransferDatabase acLink, "Microsoft Access",
"c:\Temp\JETS2.mdb", acTable, "tbl Clients", "tbl Clients", False

Thanks in advance,

Martin
 
J

John Spencer

I'm not quite sure what you are trying to do. Perhaps what you want is:.

If DCount("[Name]", "MSysObjects", "[Name] = 'tbl Clients'") = 0 THen
DoCmd.TransferDatabase acLink, "Microsoft Access", "c:\Temp\JETS2.mdb",
acTable, "tbl Clients", "tbl Clients", False
End if

If table list is a boolean value then perhaps what you want is
If TableList = (DCount("[Name]", "MSysObjects", "[Name] = 'tbl Clients'") =
0) Then
DoCmd.TransferDatabase acLink, "Microsoft Access", "c:\Temp\JETS2.mdb",
acTable, "tbl Clients", "tbl Clients", False
End If


--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top