Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

undo/rollback 1

Status
Not open for further replies.

aw23

Programmer
Nov 26, 2003
544
IL
I have a form where the user can update live data. The form contains subforms too. There is a save button and cancel button. The save button will actually o nothing since the user is working on live data. I want the cancel button to undo whatever changes the user made. How do I do this? Remember it has to undo the changes on the whole form which includes related records on the subforms.
 
I figured out how to shorten the loading time of the form from other posts - (tools,options,general and disable autocorrect)

I have another problem when I'm trying to create a new record on my main form.
In my main form:
mcnn = nothing
set mcnn = currentproject.connection
DoCmd.GoToRecord , , acNewRec
Call Me.Custs.Form.LoadData
Call Me.CustSupp.Form.LoadData
mcnn.BeginTrans

I get an error when calling the subform's loaddata function. These functions work fine when a main form record exists even if no related records exist.
My error is "Method 'Recordset' of object '_form_custs' failed
 
I figured out why I was getting error= "method recordset of object _form_custs failed" I first needed to do an acsaverec on my main form.
I'm still stuck on the problem of adding a new record to my unbound subform...
 
aw23 said:
The problem is - how do i add a record on my subform if it's not bound? when i add a new record now to my subform the data is entered but it is not linked to my main form.
Have you tried using the before update event of the subform to copy the value of the primary key of the main form to the foreign key of the subform?

e.g. in subforms before update event:
Code:
if me.newrecord then
  me.field_name = me.parent.field_name
end if

you could bind the main form - then you only have to deal with transaction processing on the subform instead of both.
 
Thank You! I never user the beforeupdate event before. It works great!

Here's the new problem.
I have a listbox on my main form that queries my customer table for all relating records. This same form has a subform called customers which allows the user to update and add new records to the customers table. When a user adds a new record to the subform (or edits) I want the listbox to reflect the changes. I tried myLB.requery but it didn't show the changes. I think it's because the changes are being made in the transaction block and hasn't been "commited" yet. How do I show the changes without commiting?
 
why would you want the listbox to update - because any new and non-committed customer records will not be present in the underlying table. Thus you could potentially be displaying 'ghost' customers.

you could try using a call back function. type "listbox user defined function" into MS Help for more information or try .

cheers,
dan
 
Thanks but I solved it- I had to use the same connection string when requerying the listbox.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top