
Originally Posted by
hightekkrednek
Good afternoon. My first post here, thank you in advance for any help. I am new to Access and have a very small amount of experience tinkering around in c flavors.. laymans terms is much appreciated. I am trying to write a db to help my wife with her job.
db details..
DB name:blendSchedule
Form Name: frm_currentLoads
Form Source: qry_currentSchedule
qry_currentSchedule source is tbl_silo9
On the form, it has a combo box that is grabbing its rows from qry_currentSchedule(based on int_loadNumber) and only listing those that are not completed(bool_isComplete=false). When a record is selected in the combo box, it populates fields in the form. There is a button on the form called btn_completeLoad.
Instead of using vba to populate the controls on the form one would usually set the form's recordsource to the table/query in question and use the combobox to simply navigate to the appropriate row. To use a combobox to navigate a form I personally use the 'alternative' code in David-W-Fenton's answer here https://stackoverflow.com/questions/...obox-in-access
What I am wanting to do is.. while in a form, press btn_completeLoad that appends input box contents(and a couple other things) to the record selected in qry_currentSchedule.
Instead of using a button to run an append query, since your form and controls are bound to a recordset, all you simply need to do is check if the form is "dirty" and if it is then set dirty to false and the record will be saved.
Put this in your button's click event:
Code:
If Me.Dirty = True Then Me.Dirty = False
It should go like this.. select record in form via the combo box.. click btn_completeLoad, input box pops up and requests truck number, enter info and confirm.. if info is entered(!NULL) to str_truckNumber, it should change a yes/no checkbox field(bool_isComplete) in the table to TRUE.. then automatically add the current date and time to another field(dtm_completedTimeStamp) for that record for the moment the load is marked as completed. I would then like it to refresh the qry data in the combobox and in the fields of that form to omit any shown records that are marked as complete.
After Me.Dirty=False per above fires, it will fire the form's Before Update event. This is where you can validate any user input and add a time stamp, mark complete, etc. before committing the changes to the database.
Please let me know if I jumbled my request up into an incoherent mess or if you could help me with the best route to move forward here. I tried getting the button to run an append query that did this for me but i was never able to get it to associate the currently selected record in the form to the one i was trying to append data to, it kept telling me it was going to append 0 records.. otherwise it almost worked.. either my mistake or completely wrong way to go about it. Best i can tell this will require code and cant be done in macro or in an append qry.. but thats where my ignorance has gotten me so far thus here I am. Thank you for any help.
Dennis
You are welcome to zip up your database project and attach it for review.