473,461 Members | 1,313 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Inserting the records on click of command button in MSAccess form

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 3754
NeoPa
32,556 Expert Mod 16PB
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_BeforeUpdate() 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 Expert 256MB
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,556 Expert Mod 16PB
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
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,556 Expert Mod 16PB
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 Expert 256MB
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_BeforeUpdate 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,556 Expert Mod 16PB
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
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
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...
3
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...
36
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...
1
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...
1
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...
10
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...
8
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...
6
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
1
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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
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.