Use Excel app to remove rowsource db table's field (SQL)

PaulZak

Board Regular
Joined
Aug 22, 2006
Messages
105
Hi All,

I've inherited an Excel app that uses an MS Access db back-end to store data. (We have multiple users for this app, each with their own data in their DB files.) My predecessor set some fields in some tables to use the Lookup feature and one table 's field has a rowsource that's no longer valid, i.e., he hard-coded some values in the lookup's query that are now obsolete. So I want to remove the rowsource setting. Ugh! This is why I *never* set field lookups in tables, and I bet most developers out there agree.

I've created an Excel "DB UPDATER" file that I'm distributing to all the users. It will connect to their DB file and make several other updates automatically for them, such as adding fields to some tables, deleting old tables, etc. I'd like to add code that also removes this lookup from each user's table. But I can't find any SQL "Alter Table" code that will do this. I tried the following w/o success.

szSQL = "ALTER TABLE [tblDATA1] " & _
"ALTER COLUMN [Data_Type] DROP ROWSOURCE"

I also guessed at some alternatives (ROWSOURCE = "") but still no luck.

I know how to delete the rowsource manually but our db file is PW protected so users can't get into their own files, themselves (without me giving them the PW), to make the change manually. My PLAN B will be to write code that re-creates the tables not having these lookups and copy the date into the new tables. But that approach is much less desirable because I'll also have to delete and recreate joins for the table, etc. Possible... but harder.

Anyone out there know how I can remove the lookup setting in the table's field(s) using VBA from either Excel or Access?

Thanks in advance...
 

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top