473,386 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Stopping data being written to a table

I have a form with two sub forms. The form is set to data entry. The
form is bound directly to a table I have two buttons at the bottom of
the screen. One button is named reject and one is named accept. I
would like the reject button to cancel the current entry being written
to the table and the accept button to save the entry to the table.

I have tried the form.undo command and DoCmd.RunCommand acCmdUndo but
if you click on one of the subform it doesn't seem to undo the changes
(the subforms are not used to input data and are purely used for
reference) and a record is added to the table. If you do not click on
the subform and click the reject button no entries are added to the
table.

Any suggestions would be greatly appreciated.

Dec 5 '06 #1
2 1420
Mark wrote:
I have a form with two sub forms. The form is set to data entry. The
form is bound directly to a table I have two buttons at the bottom of
the screen. One button is named reject and one is named accept. I
would like the reject button to cancel the current entry being written
to the table and the accept button to save the entry to the table.

I have tried the form.undo command and DoCmd.RunCommand acCmdUndo but
if you click on one of the subform it doesn't seem to undo the changes
(the subforms are not used to input data and are purely used for
reference) and a record is added to the table. If you do not click on
the subform and click the reject button no entries are added to the
table.

Any suggestions would be greatly appreciated.
Trying to control when Access saves a record is definitely swimming against
the current. Trying to do so when you have a form with subforms is pretty
much a non-starter.

I suggest you let Access save when it wants and provide a delete button.
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Dec 5 '06 #2
On 5 Dec 2006 10:47:39 -0800, "Mark" <mb*******@gmail.comwrote:
>I have a form with two sub forms. The form is set to data entry. The
form is bound directly to a table I have two buttons at the bottom of
the screen. One button is named reject and one is named accept. I
would like the reject button to cancel the current entry being written
to the table and the accept button to save the entry to the table.

I have tried the form.undo command and DoCmd.RunCommand acCmdUndo but
if you click on one of the subform it doesn't seem to undo the changes
(the subforms are not used to input data and are purely used for
reference) and a record is added to the table. If you do not click on
the subform and click the reject button no entries are added to the
table.

Any suggestions would be greatly appreciated.
By clicking on the subform you are moving focus away from the main form. This is
a trigger for Access to save the record.

In this scenario the main record cannot be undone, it must be deleted.
Your cancel button will need something like.

If Me.NewRecord Then
Me.Undo
Else
CurrentDB().Execute "DELETE * FROM tblMyTable WHERE (MyID)=" & Me.MyID & ";"
End IF
Wayne Gillespie
Gosford NSW Australia
Dec 5 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Justin Lebar | last post by:
Sorry about the huge post, but I think this is the amount of information necessary for someone to help me with a good answer. I'm writing a statistical analysis program in ASP.net and MSSQL7 that...
4
by: Civilian_Target | last post by:
Is there any way in DB2 to automate the taking of a snapshot, for example, a function that will cause a db2 snapshot to be taken every 5 minutes and written to a uniquely named file? Am I better...
2
by: SenseForAll | last post by:
First please note I am a novice at VBA and not even that experienced with DAO/ADO and MS-SQL. Any assistance is appreciated. That said... I have an application written in Access w/ VBA. I need to...
6
by: Rey | last post by:
Howdy all. Am attempting to delete a large number of records (123K) from a table using: db.execute "delete from tblname" Then I double check (code below) to see if records still remain as...
2
by: Tilted | last post by:
Evening chaps I'm after a bit of advice, I've written a data tier using attributes, reflection and inheritance, to test it I've written a simple order entry program. Glad I did as it picked up...
9
by: Brad | last post by:
I have written some code to manipulate data/records in a MASTER (order header) and DETAIL (order details) tables. What I have written is too extensive to post but essentially trying to: 1....
5
by: Brian P. Hammer | last post by:
I have data from multiple SQL tables, some of the tables will only have one row, while others multiple rows. I load a bunch of data from the various tables and add them to a third party grid. With...
5
by: Phil Latio | last post by:
I have 2 virtually identical tables and wish to move data between them. Basically one table is called "live_table" and the other is named "suspended_table" and the only difference is that the...
10
flexsingh
by: flexsingh | last post by:
Hello there, I have a form and when data is inputted it goes into the table and I can get it out pefectly fine, the problem I have is that if the promary key is empty it will not submit, but if any...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.