locked
Make Specific Fields in a Query Read Only in a DataSheet View RRS feed

  • Question

  • Hi All,

    I have a Query that gets frields from two tables, 1 is ITEMS SOLD, and the other is STOCK. They are linked to gether using a BARCODE, My query that I have takes the BARCODE from the ITEMS SOLD table and gets all of the ITEM DESCRIPTION, SIZE, etc from STOCK.

    I want to use my query to add items to the ITEMS SOLD table by adding the barcode, then the query will get the info from the STOCK table. This works fine, but y problem is that I have the query on a form as a datasheet from to add new items, but I dont want the users to be able to edit the fields brought from the STOCK table, when they add an ITEM as this then changes it in the STOCK table,

    Is there a way to make the fields brought from the stock table read only, ie, They cant change them?

    Thanks

    Tom

    PS: I am using Access 2010, and my STOCK table is a linked table from another database

    Thursday, February 16, 2012 12:45 PM

Answers

  • In a form: set the Locked property of the controls bound to fields from the STOCK table to Yes. This will work in form view and in datasheet view.


    Regards, Hans Vogelaar

    • Marked as answer by t0m46 Thursday, February 16, 2012 8:03 PM
    Thursday, February 16, 2012 12:59 PM

All replies

  • In a form: set the Locked property of the controls bound to fields from the STOCK table to Yes. This will work in form view and in datasheet view.


    Regards, Hans Vogelaar

    • Marked as answer by t0m46 Thursday, February 16, 2012 8:03 PM
    Thursday, February 16, 2012 12:59 PM
  • In addition to setting the control's Locked property to True (Yes) if you also set its Enabled property to False (No) the user will not be able to move focus to the control.  Setting both properties also preserves the original appearance of the control, whereas if you only set the Enabled property to False, this will grey it out.  It's possible that you might prefer this of course, to give a user a visual indication that the control is not updatable.  Generally this is more usually done dynamically with unbound controls in a dialogue form, however, to indicate that they are not available in a certain context, rather than with bound controls showing data.

    Ken Sheridan, Stafford, England

    • Proposed as answer by David924 Friday, April 24, 2020 12:28 PM
    • Unproposed as answer by David924 Friday, April 24, 2020 12:28 PM
    Thursday, February 16, 2012 1:44 PM
  • The current answer does not address the question, it modifies the question to fit the answer.

    The Question: How to make a field read only in a query datasheet, not in a form.

    The answer is to modify the field being displayed so that it is an expression.

    As an example for a numeric field [Cost] modify it to be:

         Cost :[Cost]+0

    Note that the space before the : is not a space but ascii character 255, entered by holding down the alt key and typing the number 255.  This allows the column name to appear the same as the field name.

    As an example for a string field [Vendor Name] modify it to be:

         Vendor Name:[Vendor Name] & " "

    In this case the alt+255 character is inserted in the column name in place of the space in the multi-word field name.

    Friday, April 24, 2020 12:52 PM
  • End users should never enter/edit data directly in a table or query, only in forms, so it makes sense to provide a method that works in forms. Moreover, locking controls is simpler than creating calculated columns with special characters in the name...

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Friday, April 24, 2020 1:45 PM