473,804 Members | 3,373 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inserting the records on click of command button in MSAccess form

2 New Member
Hi All,

I have created a form in MSAccess and linked that form with a table.
now in the run mode if i am entering any thing in the textbox and closing the form with out clicking on add record button then also the record is getting added in the table which I don't want to happen.

What I want is only on click of command button the record should go in the table. If there is a new record in the textbox and I have closed the form without clicking add record button the record should not go in the table.

Pl help me............. .

With Regards,

Kashif Khan
Nov 16 '07 #1
7 3793
NeoPa
32,579 Recognized Expert Moderator MVP
This is a bit of a strange question as the form will handle adding and changing records if the datasource is bound.
You can stop this in the form's Form_BeforeUpda te() event procedure if you want.
I'm not sure how you're getting the add to work behind your button. Perhaps you could post the code (remember to use the CODE tags).
Nov 16 '07 #2
sierra7
446 Recognized Expert Contributor
The reponse you are describing can be achieved using an UNBOUND form but this is a BIG DEAL because you must then write your own code to write data into your controls in the first place, then seperate code to sequentially read the controls to save changes to the database. If you want navigation controls..you must write your own!
Nov 17 '07 #3
NeoPa
32,579 Recognized Expert Moderator MVP
This is exactly why I didn't suggest that approach myself but asked for more clear information. Heading off in that direction if it's not necessary is definitely something to avoid.
A response to my earlier post may help to find a more "Access" based approach.
Nov 19 '07 #4
gibbo
1 New Member
I actually was wondering how to do the same thing. I am using a form to enter some data into a table, but instead of automatically being entered into the table I want it to be added upon clicking a button.

I am a complete newbie when it comes to Access, but I understand the difficulties in making the text boxes unbound and then having to write code to support the entering of the data.

So, is it possible to enter something in a form and not have it update the table until after you click an "update" button? And if you entered all the data in the form and then clicked exit, it wouldn't add the data to the table.

Thanks for the help.
Nov 19 '07 #5
NeoPa
32,579 Recognized Expert Moderator MVP
As this is pretty much on topic - I'll leave it in this thread (Questions from different members should normally be in their own separate threads).
The way to do this is to have event procedures in all the places that could otherwise trigger an update, and set the Cancel parameter to False when you don't want the update to occur.
Nov 20 '07 #6
sierra7
446 Recognized Expert Contributor
This is exactly why I didn't suggest that approach myself but asked for more clear information. Heading off in that direction if it's not necessary is definitely something to avoid.
A response to my earlier post may help to find a more "Access" based approach.
I think I had my fingers rapped by mentioning unbound forms! but I totally agree with NeoPa not to go down that route unless absolutely essential. As soon as you do, you lose lots of "Access" features and are effectively writing VB with Access tables.

With ref to Gibbo, the way "Access" wants to work is to click to add a BLANK record and then update it. You can verify each field as it is entered so why would a user want to abandon data? If interrupted, the job can be completed later rather than restarted. The default (including clicking Exit) is to automatically save the data rather than relying on the user to press a 'Save Data' key.

The Form_BeforeUpda te event is a good place to check to confirm or escape saving the data if a user felt it was incorrect or incomplete but any Autonumber fields will already have been incremented (and may have been incremented further by other users). This could result in a gap in Order numbers and the like. If this was important you could consider writing the missing numbers to an audit trail, as even this would be less hassle than an unbound form.

In 'older' systems you used to see separate screens for Add, Edit, Browse etc and this is possibly where the urge to 'click to add' has come from. This is another route not to go down on a whim!
Nov 20 '07 #7
NeoPa
32,579 Recognized Expert Moderator MVP
I think I had my fingers rapped by mentioning unbound forms!
...
Obviously you understood where I was coming from Sierra. I detect an experienced hand :)
In truth though, my intent was to warn the OP rather than have a dig at you per se. I look forward to coming across more of your posts :)

* Edit *
Rereading my post it does sound more personal than it should - My bad.
Nov 20 '07 #8

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

Similar topics

6
1826
by: Melissa | last post by:
How do I write the following expression so if I click through the two parameter dialogs I get all records? Between And Thanks! Melissa
0
3010
by: pd123 | last post by:
I'm new to C# and .net and I'm trying to create a form that will register users in a sql server database. I have the following code but when I run the code I get an error " The name 'Peter' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted. Where Peter is the value entered in the textbox for firstname (fnameTBox) I'm sure the problem is something obvious but I...
3
2672
by: neelesh kumar | last post by:
sir, i have a java applet j2sdk1.4.1_01 .i am using msaccess database . Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"). in my program i want to get records from access table in a new frame randomly(random records).In my frame i have next button now if i click next button, next record is coming from the table. i want to get random records from the table and come on the frame one by one when i click next button. how to write code in java....
36
4817
by: beebelbrox | last post by:
Hi, I am new VB programming in Access and I am requesting help with the following code. WIndows OS MSaccess 2003 This code is attached to an unbound form that will display a specific recordset based in information passed to the form from another form. The problem I am having is that for each of the case statements the proper records (values and Number of records) are being returned but the movement commands do not work or do not display...
1
11506
by: kirkus84 | last post by:
I am currently trying to do a multiple record mail merge through a query via a command button on a form. The query basically displays customers who have said yes to privacy. The user inputs a date into txtDate on frmDate and the clicks "View Queried Privacy Records" Once they click this it opens the query form frmPrivacy which then has a command button cmdMailmerge to perform the mail merge and print the records that result from that query. (I...
1
1283
by: kashif khan | last post by:
Hi All, I have created a form in MSAccess and linked that form with a table. now in the run mode if i am entering any thing in the textbox and closing the form with out clicking on add record button then also the record is getting added in the table which I don't want to happen. What I want is only on click of command button the record should go in the table. If there is a new record in the textbox and I have closed the form without...
10
1834
by: Clamato | last post by:
Good Morning, I'm working with a form that basically add's a users windows logon ID, first name, and last name to a table. A list box on this form is then requeried once added displaying the names in this table. I'm ultimately trying to make it so the user can't add their information twice in this table. Well, you would think just making their ID the PK in the table would work, however I'm running into an issue with this. The user...
8
1446
by: mvdave | last post by:
Hello all & I hope I'm posting in the right place.. I need to load a temporary table with a range of sequential dates, passing it a beginning and an end date from a criteria form. I have created the form FrmMakeDayFile with 2 unbound fields and . I simply want to be able to click a button and have a routine of some sort append records to the table tblDates with field Ddate inserted starting from txtDateFr and adding a new record for...
6
8808
by: emrodge | last post by:
I'm using Access 2007 on Windows Vista and am having some problems trying to configure a simple button. There are two tables called Clients and Contacts which are linked on clients.id and contacts.client_id. There are two forms associated with each table and I am trying to create a button to navigate from the Clients form to the Contacts form (which is a split form) but only to display the contacts where the current clients.id =...
0
9705
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9576
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10567
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10323
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10310
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4291
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3809
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2983
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.