Update Records on Button Click

rfaircloth

Registered User.
Local time
Today, 12:23
Joined
Jun 26, 2014
Messages
15
I have a form listing out a bunch of clients. There is a button associated with each client that pulls open a new form with additional client information. There is information that is calculated on the backend and stored in the database when a user is inserted or different fields updated (i.e. there are reports that are due different time frames after the clients admission date. I automatically populate the database with those dates once the clients admission date is updated).

The problem I am having is that when I enter a new client or update a current client with new information and then click the button to go to their details page, those auto-populated dates are not populated. I am calling a subroutine that is within a module when the button is clicked. The subroutine works fine at other instances throughout the application so I know there is no issue with the code. I even call it if they click the close button, but before the information is auto-populated, I had to run a Me.Requery on the close button. I think this is because the records are not actually being updated in the database. I even have a DoCmd.Save acForms, "Clients" command before running the Call updateDatabase subroutine, but that doesn't do the trick. I can't run the Me.Requery after the click of the details button because when I do that it always opens the details form to the first ORDER BY record. I think that I need to update the selected record and re-call it in order for this to work. Anyone have any suggestions? Thanks in advance for the help!
 
I think this is because the records are not actually being updated in the database.
Quite right!

Depending on where the button is placed, use this code:
Code:
if me.dirty = true then
    me.dirty = false
end if
Replace Me. with the correct reference if needs be.
 
I did see that code in my research but I wasn't quite sure how to use it. Do I need to first identify the selected row? Or just loop through all the rows in the form? The button is within each row of the continuous form so the end user will click on the button for each corresponding client.
 
You put the code in the Click event of the button, just before you open report.
 

Users who are viewing this thread

Back
Top Bottom