473,408 Members | 2,009 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,408 software developers and data experts.

data entry form creates new record every time it is opened

I have a form used for data entry of new records. Some of the fields on the form have a default value. One of the default values is derived from a combo box on a previous form (eg: create a new record for specific item).

There are some times when a user may open the form and then close it without entering anything. When this happens a new record is created that is mostly blank (except for the default values).

Is there any workaround to this? I only want a record to be created when the save button is clicked.
Mar 27 '07 #1
6 1491
missinglinq
3,532 Expert 2GB
Place a second command button next to your Save button, name it CancelSave, and use this code behind it:

Expand|Select|Wrap|Line Numbers
  1. Private Sub CancelSave_Click()
  2.    Me.Undo                                      
  3. End Sub
Mar 27 '07 #2
Denburt
1,356 Expert 1GB
Place a second command button next to your Save button, name it CancelSave, and use this code behind it:

Expand|Select|Wrap|Line Numbers
  1. Private Sub CancelSave_Click()
  2.    Me.Undo                                      
  3. End Sub
Good fix and it will help in case they start typing and decide to get out.


You may want to look at the VBA code used to populate the one control from the comboBox.

Plenty of times this can be changed:
Expand|Select|Wrap|Line Numbers
  1. Me!MyControl = Forms!ABC!ComboBox.column(0)
  2.  
To something more like this and prevent such an issue as well as keeps the next record ready to go with that same value:
Expand|Select|Wrap|Line Numbers
  1. Me!MyControl.defaultvalue = Forms!ABC!ComboBox.column(0)
See where I am going?
Mar 27 '07 #3
I think I see how that can be useful. No change is being made to the record, so there is nothing to save. Are there any other benefits to using default value property vs. forcing the value?

thanks for your help

Good fix and it will help in case they start typing and decide to get out.


You may want to look at the VBA code used to populate the one control from the comboBox.

Plenty of times this can be changed:
Expand|Select|Wrap|Line Numbers
  1. Me!MyControl = Forms!ABC!ComboBox.column(0)
  2.  
To something more like this and prevent such an issue as well as keeps the next record ready to go with that same value:
Expand|Select|Wrap|Line Numbers
  1. Me!MyControl.defaultvalue = Forms!ABC!ComboBox.column(0)
See where I am going?
Mar 27 '07 #4
Denburt
1,356 Expert 1GB
No change is being made to the record, so there is nothing to save. Are there any other benefits to using default value property vs. forcing the value?
Sorry if I wasn't clear the following would be just like typing it in by hand which creates the new record that isn't completely filled in.
Expand|Select|Wrap|Line Numbers
  1. Me!MyControl = Forms!ABC!ComboBox.column(0)
The following will not cause the above problem and will allow your control to populate this value for every new record they create.
Expand|Select|Wrap|Line Numbers
  1. Me!MyControl.DefaultValue = Forms!ABC!ComboBox.column(0)
Mar 27 '07 #5
how does this differ from the autowizard code?

Expand|Select|Wrap|Line Numbers
  1. DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
  2.  
Place a second command button next to your Save button, name it CancelSave, and use this code behind it:

Expand|Select|Wrap|Line Numbers
  1. Private Sub CancelSave_Click()
  2.    Me.Undo                                      
  3. End Sub
Mar 27 '07 #6
Denburt
1,356 Expert 1GB
Well if you ask me I would say it is just a nasty way of achieving the same result. The problem lies in the version of access you are using and when you upgrade, menu bars are much more likely to change than the code syntax (I just read about this issue with one of the newer releases).

Another would be:

DoCmd.RunCommand acCmdUndo

I could probably give you sixty ways to achieve the same result however I think missinglinq was on target a lot of this depends on the person and the experiences that they have had. If I did some digging I know I could find an article that stated that the DoMenuItem was on it's way out and was to be replaced by Runcmmand but they never removed it and some of the commands you use domenuitem on aren't available elswhere.

According to the VBA help file:
The RunCommand method replaces the DoMenuItem method of the DoCmd object
O.K. so I like to back things up with facts... Simply type in Runcommand in the VBA window highlight it and press F1
Mar 27 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Iain Miller | last post by:
Struggling a bit here & would be grateful for any help. I have a table which has a list of people in it. Each person has a unique ID automatically allocated by Access but also belongs to one of 5...
2
by: edworboys | last post by:
I have designed a data entry form with a number of fields and a sub form. The first field (Country) is a combo box and the user selects a country. This, in turn reduces the number of options in the...
5
by: Aspnot | last post by:
Background: I have a data entry form that is bound to a DataSet. This DataSet contains 9 tables and the form displays data from each table in textboxes, not a DataGrid. One of the tables in the...
2
by: x | last post by:
hi i am a pilot by profession. i want to create a database of my logbook using ms access 2002. i am facing a problem regarding the format of time field. when i select "Data/Time" data type for my...
30
by: Charles Law | last post by:
Here's one that should probably have the sub-heading "I'm sure I asked this once before, but ...". Two users are both looking at the same data, from a database. One user changes the data and...
17
by: Timothy.Rybak | last post by:
Hello all, This is my first attempt at an application, so kid gloves are appreciated. I need to make a very simple form that only has a few elements. One is TraceCode - a text field that is...
1
by: NumberCruncher | last post by:
Hi All, I am struggling with setting up my first system of tables, forms,and reports, and could use your help! I am setting up a database to keep track of the production of a produced item. The...
20
by: hippomedon | last post by:
Hello everyone, I'm looking for some advice on whether I should break the normalization rule. Normally, I would not consider it, but this seems to be a special case. I have created an...
11
by: dizzydangler | last post by:
Hi, all! I'm a new user, looking to get some help on a form problem in MS Access 2007 I haven't been able to crack. I've built a form that prompts users to enter new record data, then click...
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...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.