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

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.

Related

What Event is fired when Access is leaving one record and moving to next?

I am developing a MS Access 2016 application with bound controls on Forms. Late in the process I decided I want a multi-select listbox.
From what I can see, you can't bind a multi-select listbox to a table. I'm okay with parsing the listbox when about to leave that record, and putting a comma separated list of values in a bound, non-visible text box. And then on arriving at the new record, setting the values in the listbox based on the values in that record's textbox.
The Current event lets me know when I arrive at a new record, but is there an event that lets me know I'm leaving a record? Before Update only works if the current record is changed, not just navigating to a new record. I suspect I'm missing something real basic.
If you want to parse a field and manually update it to a table, use the Before Insert and Before Update events. Don't do anything with navigation, because then you're likely too late.
Also, make sure to dirty the form when the value of the list box changes (Me.Dirty = True in the On Change event), so the update fires when navigating.
Or, like krish KM says, just make sure your text box changes every time your listbox changes.
That's more reliable than accounting for navigation, filtering, closing the form, manually saving, etc.

Ms Access Datasheet view - only one column editable

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.

Updateable subform adds "#http://#" to end of hyperlink field when edited

I have a form with a subform that lists current material information being entered on the main form, like a log/history view.
On the subform there is a field that specifies which skid the product was assigned. I made this field a hyperlink so that I could use the OnClick event to launch a report and be able to extract row information needed to generate the proper summary.
That works great, and I thought it was finished until I attempted to edit the skid number from within the subform.
Allowing edits in the subform is a project requirement. Editing the skid number in the hyperlinked field breaks my code. Access automatically appends #http://# to the end of whatever value I enter into the cell and updates the table with this string. That row then gets omitted from the report because I'm keying off of the skid numbers. By design, this hyperlink has no path or address, I just use it to determine which row is being clicked.
How can I prevent Access from appending the #http://# while keeping the "Is Hyperlink" property to Yes? Is there another property to set this behavior or should I use the AfterUpdate event to undo the addition, which just seems like a waste of resources?
I am running Access 2010.
There is a long and very thorough article here that I will not copy ;) It elaborately states why its a bad idea to even use the hyperlink-field and what to do to get the same result you need without a hyperlink-field.
Basically, the main point of the hyperlink-field is all that behind the scenes shenanigans you cannot do anything about - and thats not what you want as a programmer.
The Hyperlink-field internally consists of three parts: A Text-part, a Link-Part and a Tooltip-Part. And although you can access them separately, access always tries to create a link.
You can try to format the data you have in the internally used format (DisplayText#Address#SubAddress) but I think that is not what you need...
So I think you best take Philipps advice and change your field-type.

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.