Ms Access Datasheet view - only one column editable - ms-access

There is access datasheet sub-form and users should only be able to edit count column. How can that be done ?
Currently, If I change the form property Allow Edits = True, users can update any cell.
Also, the user should be able to enter different count values. If a user types 1 in first cell, it get copied for all the rows.
How can this be achieved?

For each control on the form that you don't want editable, set the Enabled property to False (or the Locked property).
For the count copying to all rows, we need to see the query that this datasheet is based on to answer that. If the count is an unbound textbox, you will get the behavior you are seeing as Access will only create a single instance of the control, then repaint that single instance across all rows (note that this is the same with continuous forms as well)
Instead, create a query that has this field (or a dummy table) and bind to that, making sure to bind the textbox to the dummy field, and then you should be able to edit the value on a per-row basis.

Related

How do I get my Access form to re-open to the last unbound text box entries?

I have created a form to update criteria in various queries in my database. I have 4 unbound text boxes. The user enters the new dates into the text boxes and I've added a button to run the queries. The query results look great.
The problem is, I want to be able to close the form and upon re-open have the dates that were last entered re-appear. Instead, the text boxes are blank and the user has to re-enter the dates.
Basically, the same dates will be used for a month, then at month end, the dates will change. I would like to be able to set the default to the last entry.
Is this possible?
Rather than using unbound textboxes, consider creating a table containing a single record to store the values entered in each textbox, and then use the table fields as the Control Source for each textbox.
This way, when the user enters/changes the value in the textbox, the underlying table record is automatically modified and will be automatically reloaded when the form is reopened.
You can also set the Allow Additions & Allow Deletions properties both to No in the Form Data properties, so that the user cannot create/delete the record in the underlying table being used to save the textbox values. Make sure that Allow Edits is set to Yes to ensure that the user can change the values in the textboxes, and that the Recordset Type is Dynaset so that it can be edited.
Using this method should also not require any changes to the rest of your existing application, since the values held by the bound textboxes may be read in the same way as if they were unbound.
It's hard to know exactly what you're asking without seeing the code you have, but if you are using VBA, you could look into the difference between hiding the form and closing/unloading the form as described in this answer. If you hide the form, it won't be visible to the user, but it will still be loaded, so your text boxes should keep their values. When the user needs to interact with the form again, you can un-hide it.

retrieving data from a query inside a form

I have a form in MS access which contains information about customers of a store (It's directly connected to the table because I want to be able to edit fields).
I want to have a field inside the form which contains information calculated in a query in the form of (ID, Value)
How is it possible?
Derive data using either VBA or Macro
Since your form is bound, and the field in your query is not a field in the bound table, you can simply add an unbound control to your form. You can use a textbox control, draw on form, and it should default to an unbound control. To check, select the new control and confirm that its control source property is blank.
I am assuming that your query already has form references that are filtering the results based on which record you have open on the form. If not, you will want to put in the ID field's criteria of your query: [Forms]![MyForm]![MyBoundIDControlNameOnForm]
In your form's On Current event. Open the code builder and type this into the On Current event:
Me!txtMyNewControlName = DLOOKUP("[Value]", "MyQueryName")
DLOOKUP has a third argument that allows you to add criteria. I am assuming that your query only returns a single row with the form reference criteria, so there is no need to tell DLOOKUP which row in the query results to return.

textbox in continuous form populated from different table

I have a continuous form in an access 2010 database that outputs a separate row of data for each customer from a customers_table. The continuous form is for data display only, and no data entry or editing is allowed. One of the textboxes on the continuous form is populated with data that was entered using a combobox in a different form used for data entry. In the textbox on the continuous form, enabled is set to no, and locked is set to yes, so that the textbox is not editable in the continuous form. However, in the separate data entry form, the combobox entered the id for the selection the user chose, instead of entering the text. Therefore, in the continuous form, only an id number is shown, when the user needs to see the text of the specific option which is encoded in that id number.
I think I want to keep the id in the customers data table, in order to retain freedom to make subtle changes in the combobox options later.
So how do I modify the textbox in the continuous form to populate with the textual value associated with the id number? This would seem to involve some sort of SQL like:
"Select textValue FROM comboboxsource_table WHERE comboboxsource_table.ID=textbox.Text"
However, I have no idea where to put this in the Access GUI. The Control Source field in the Data tab of the property sheet for the textbox does not seem to allow this sort of syntax.
If you're not editing the data, put a query behind the form instead of a table. Then, just pull the field you need into the query and VOILA! Problem solved. :o)

Textbox calculation appears only after navigating through other records in access

I have a form that is linked to a table in Access. I have an additional field which displays the sum of a few fields in the table. This field on the form is not connected to the table. I have the sum displayed on the form but what I noticed is that the sum does not appear until I move away and navigate to another record and come back to the original record. I don't see the addition as soon as I enter values in the respective fields.
Can someone help with this issue?
It sounds like you need to add some code to the After Update events of the controls for the fields used in the sum. That code can call the .Refresh method of the control that performs the calculation and update the total.
Edit
Another possibility is that there could be ambiguity between control values and field values if they have the same name. In Design View for a report if you drag a field from the "Field List" and drop it into a report then Access creates a report control with the same name as the field. This can confuse matters later because if any expressions refer to =[SomeColumn] it's not clear whether that refers to the field or the control. Often simply renaming the controls to something like txtSomeColumn can help if a report is acting strangely.

How to filter a table field's listbox by the current record

How do I set up a table's field so that the listbox is filtered by that row's data?
I have a master table (TblMain) with 2 important fields: Client and Division. Currently, the Division field is set up as a simple Listbox that pulls from another table (TblDiv).
However, the Divisions are specific to each client with little overlap. My current basic setup doesn't make that distinction, so any division can be chosen for any client.
How do I set up Division so that the listbox is specific to that row?
I've tried doing an inner join within the row source (i.e. Select TblDiv.Div from TblMain Inner Join TblDiv on TblMain.Client=TblDiv.Client) but that doesn't seem to work, probably because I'm not referencing the Client value of the active row.
(I should add I'm not talking about Forms or Reports. Just the Table object)
Are you trying to add a look-up field to a table? This is almost never a good idea. Are you trying to filter a combobox on a continuous form? You cannot sensibly do this - any change will affect the appearance of every row, which is confusing to the user. There are work-arounds. For example, you can show a textbox for the Reference and a "Change reference" combo. This will avoid confusing users because the bound textbox will not update. You can set various properties of the change combo with conditional formatting to make it all prettier. Alternatively, you can use two subforms or a pop-up form to edit data.