I’m making a fairly simple form with a button that opens a table for the user to read (but not edit). Here’s the command:
DoCmd.OpenTable "Tbl_SendLog", acViewNormal, acReadOnly
- The good part: As expected, the user can’t add or change records
- The bad part: The user can still add entire columns. Even better, Access doesn’t even have a “Do you want to save your changes” prompt when closing the table. It just saves it.
I’d have thought the acReadOnly would take care of this. Apparently not. So my question is: How do I modify this so the user can’t add columns?
(If I need to, I’ll make a form or report for the table, but if there’s a simpler option I’ll go for that instead)
The easiest way (=the way with the least work) would be to use a query, as already suggested by Remou in a comment.
Just make the query
select * from Tbl_SendLogand open it like this:Pro: When you right-click on the query, there’s no “Add column” in the context menu (like when you open the table directly), so the user can’t add columns
Contra: The user can still switch to design view in the query and mess up the query, so maybe after that it won’t work anymore.
If you can live with that (= if your users are unlikely to change the query), you can just do it like this.
If you can not live with that, building a form or a table (as you already suggested in the question) is probably the best solution.