Need prompt to save changes in Windows form when changing displayed record - vb.net

I am relatively new to programming, so this may be an easy one. I have a Windows form that connects to SQL Server and displays the data in a form where a user can edit and add or delete records (via databinding). The form works well, and has record navigation controls as well as context menus that allow the user to filter data on any field.
Currently, the user can make changes and switch to new records, etc... but changes are not applied until the user clicks the "save" button. However, I'd like to prompt the user to save records whenever the user navigates to a new record (either through navigator or through application of a filter which displays a different record).
What event can I use that will trigger whenever a different record is reflected in the form?
Thanks,
Jay

Related

Allowing User to Select off of Partial Records in a Continuous Form in Access

I am creating a form in access to allow users to input multiple production records for a day.
The form is set as a continuous data entry form and has data validation in place to ensure the information being entered is consistent.
I am having a problem where if a user starts typing something on a new entry, they essentially have no way to back out of it or cancel the entry without completely filling out the form.
I want to keep the data validation to ensure the data being recorded is accurate, but also do not want to lock users into an entry unless it is completely filled out.
I think the ideal would be to allow users to create a new record or select other records without needing to save the current record.
If it would be possible to make it so records only save when a button at the top of the form is pressed I think that would be ideal, but I have not found a good way to do this without requiring it on every single entry.
I have attached a picture of what I am talking about, there could be various error messages but essentially if you try to click off when a record is incomplete it will give an error until the entire form is filled out.
Example of Error Message and Image of Continuous Form
'deselect' without saving but still save what had been entered up to
that point.
That you can simulate by setting the DefaultValue of each control in the AfterUpdate event of each control:
Me!SomeTextBox.DefaultValue = Nz(Me!SomeTextBox.Value)
However, I'm not sure that will be a good idea. And you may have to reset the default values when opening the form.

Dynamic action to update database record AND redirect to a different page

I'm building a system of modal dialogs to allow users to edit database records.
The user clicks the "Edit" button on a specific row in a report somewhere
A modal dialog pops up, with fields that the user can edit and manipulate
The dialog has four standard buttons the user can select: Cancel, Delete, Save, and Create
Let's start with the Save button.
By default for modal dialogs, the Save button has the following behavior:
I presume this 1) submits the information from the items in the modal dialog (which refreshes the browser, closing the modal dialog), and then 2) performs the SQL UPDATE action with the submitted information, in time for the refreshed page to include the updated information?
This is fine, but I need to:
Avoid refreshing the browser (e.g. submit individual items, rather than the whole page), and
Manually redirect to another modal dialog (a different page) AFTER the SQL UPDATE action is completed
I presume this can be accomplished with dynamic actions, but I don't know how.
How can I ensure the database action is completed, before the dynamic action which navigates to a new page?
Manually redirect to another modal dialog (a different page) AFTER the SQL UPDATE action is completed
I'm thinking of creating a branch with Server-side condition set to "When button pressed" (for every button), or perhaps "Request is contained in value" where request name (by default) equals button name.
So: button would first do its processing part, and then branch to another page, without involving dynamic actions.

Issues saving current record from custom dialog

I am currently developing a custom app in Maximo Asset Management where i have form and an empty DataTable that have a button, when user clicks this button, a custom dialog appears and user can select a related record from this dialog on a data table to process it by clicking a button to launch an action script. The problem i am facing is when system finish process the record, it saves correctly, but application shows the first record of table and not the current saved record, so user gets confused when this happens.
Let me put an example, lets suppose the first record id of my custom table is CC1055 and the current saved generates as CC1156, when i close dialog after process record with automation script custom logic, the systems shows the record with id CC1055 and not the new saved record CC1156, postdata: I use Maximo 7.5.0.9
I had the same issue. The reason Maximo goes to the first record in the table is that it does not know which record to display after opening and closing your new custom dialog and saving the record.
The simplest solution is to add savemode="ONLOADUNLOAD" in your custom dialog tag in xml.
This will save the record before you open the dialog and Maximo will know to which record to return after closing it.

Need To Revert Multiple Controls Back To Previous Values

I have the following situation where I have multiple controls on a form. The user can select an Edit mode which allows them to modify the contents of the controls (textboxes, checkboxes, comboboxes, etc.) After editing has been made, the user can either select the Save or Cancel button.
Obviously clicking on save will save all changes to the database, however, if the user clicks on cancel, I want to 'somehow' revert all controls back to their previous state.
Currently, when the user clicks on cancel, the form turns off edit mode, but the controls remain with all the changes made until they reload the form.
Is there an easy way around this, or do I need to reload the entire form content from the database each time the user clicks on cancel?
Thanks in advance.
I'm just going to outline a possible solution here.
You could have a dictionary in your form in which you store the content of your controls whenever a user first modifies them, indexing them by the control name.
When the user starts modifying a control, you check if the control already exists in the dictionary. If it doesn't you add a new entry to the dictionary with the current value of teh control.
If the user cancels the editing process, you can loop through the dictionary, find each control in your form by its name (Form.Controls(ControlName) or something like that I think), set its value back to what it was and remove the entry from the dictionary.
It's not the most elegant solution as it will involve linking up all your controls to the TextChanged event or equivalent to capture their value when they are modified...
To avoid that, you could fill the dictionary right at the start when you load your form, after populating the values from the DB and then only set those controls' value back which have a different value when the user cancels.

How to edit a record through a form on MS Access?

I'm new to Microsoft Access and I'm having a trouble implementing something.
Basically, I have a form with a combo box, some text boxes, and a command button.
What I want to do is have the user select a record from the combo box, which then populates the textboxes (I've already managed to do this). Once the data has loaded into the textboxes, I want the user to be able to edit the info in the textboxes, then press the command button so that it updates that record in the table.
This looks like the same odd form where you had trouble with delete. It sounds like you are working from the wrong end. Create a form based on a table or query, then add a combobox to find records on the form based on the selection. There are wizards to guide you through. You will then have a standard Access form where everything works as expected. When textboxes are changed, the data will be updated as soon as you move to another record, there is no need for save, it is the default for Access.
If you wish to use non-standard unbound controls, you will need to update with SQL or stored queries.