delete or prevent records after cbo change ?

piet123

piet
Local time
Tomorrow, 00:26
Joined
May 24, 2004
Messages
66
Hello, I HAVE searched the forums for many days but I could not find a solution. Maybe I'm not sure what to look for...

The MAINFORM_1(single form view) is based on a Query and has a cbo named 'cbo_client'. This cbo is for a field named [client_id]. The AfterUpdate [event] of 'cbo_client' does a requery on a field in the the following SubForm:

In the SUBFORM_1(datasheet) (based on another Query) is another cbo named 'cbo_subclient', with a select statement of 'Select (all the needed fields) FROM tbl_subclient WHERE ((([tbl_subclient].[subclient_id])=[Forms]![mainform_1]![cbo_client])).

Everything (incl. the REQUERY) works fine, and all the tables gets updated with the records the way it should. No problems.

But this is where i get stuck...: Once the user has entered data in the SUBFORM_1 datasheet, and then >changes the 'cbo_client'< on the MAINFORM_1, it requery the subform like it should, BUT the previously entered data in the subform is already written to the table!

So, I need a way to prevent the data in the subform from beiing stored if the user changes the cbo on the mainform (for a second time). OR prevent the cbo on the mainform from beiing changed after the subform is completed.

I hope you understand what I'm trying to do...

Please, just a point in the right direction and i'll battle it out from there.

Thank you.
 
If it helps, the SubForm records are automatically saved when the SubForm looses focus.
 
Thank you for the (quick) reply.

B ut if the user selected the wrong client by mistake (cbo_client), and have already entered data in the subform, how then can i let the user go back to cbo_client to change to another client ?

Somehow I would like to prevent the subform data from beiing stored until a cmdButton is clicked. Or is there perhaps another way around this ?
 
The classic computer problem. How many time do you ask "Are you sure?". The SubForm's BeforeUpdate event would be the place to ask the question. You can then do a Me.Undo to cancel and changes made to the SubForm.
 
Thank you!

That confirms my thought of a Msgbox to the user for "Are you sure..." but i was hoping that there was a more (elegant?) way of doing it.

Thanks anyway.
 
You can make the MsgBox fairly complete. "Are you sure you want to change ABC Company to ..."
 

Users who are viewing this thread

Back
Top Bottom