473,387 Members | 1,440 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,387 software developers and data experts.

How form event code works on datasheets

167 100+
I hope I can explain this to make sense..... I have a form (datasheet) and the record source is TABLEA. TABLEA has 3 columns defined as required keys, COL1, COL2, COL3. When user is in row in datasheet doing data entry, I have put some validation code on the 'exit event' of each column to do some validation. The problem that I am having is that the user can enter data in COL1 or any COL and use the mouse to click into a different column so they actually did not execute the 'on exit' event since they did not go into the column. When they do this, they get MFD error because they skipped over a column that is defined as a primary key on the table. So, I thought I would try also putting the same validation on the Form event "Before Update", however, if they key COL1, then decide they don't want to enter it and hit the escape key the "Before Update" form event executes and runs the validations for each column and it seems to get 'stuck' and pops up my warning messages from the validation over and over.
I wish I could tell users they must tab through each field... but they do not want to do it that way, they want to skip around on the record. Any suggestions on how to handle this????
Mar 26 '08 #1
5 6424
janders468
112 Expert 100+
It sounds from your description that they are adding new records. Typically I wouldn't let users make this change directly on the table, it would probably be best to have a data entry form (for example with three textboxes, one for each column). Don't bind the textboxes to the underlying data and provide a button which uses these values to trigger a query appending these values to the table. This way you can loop through all of the text boxes and validate the data for type, nulls, etc.
Mar 28 '08 #2
I hope I can explain this to make sense..... I have a form (datasheet) and the record source is TABLEA. TABLEA has 3 columns defined as required keys, COL1, COL2, COL3. When user is in row in datasheet doing data entry, I have put some validation code on the 'exit event' of each column to do some validation. The problem that I am having is that the user can enter data in COL1 or any COL and use the mouse to click into a different column so they actually did not execute the 'on exit' event since they did not go into the column. When they do this, they get MFD error because they skipped over a column that is defined as a primary key on the table. So, I thought I would try also putting the same validation on the Form event "Before Update", however, if they key COL1, then decide they don't want to enter it and hit the escape key the "Before Update" form event executes and runs the validations for each column and it seems to get 'stuck' and pops up my warning messages from the validation over and over.
I wish I could tell users they must tab through each field... but they do not want to do it that way, they want to skip around on the record. Any suggestions on how to handle this????

Try using the "After Insert" or "On Dirty" event for the form, as opposed to the field event.
Mar 28 '08 #3
missinglinq
3,532 Expert 2GB
"I wouldn't let users make this change directly on the table, it would probably be best to have a data entry form"

janders468, please read threads carefully before responding! The OP clearly stated that

"I have a form (datasheet) and the record source is TABLEA"

No mention is made of the users entering data directly in the table!

Doing validation to assure that fields actually have data in them (as opposed to validation to assure that the data entered is of the proper type) should always be done in the form's BeforeUpdate event, for the very reason mentioned; doing the validation in a field event doesn't work if the user doesn't at least tab/click into the field. What you need to do is to post your validatrion code from the BeforeUpdate event that was causing the problem.

Linq ;0)>
Mar 28 '08 #4
janders468
112 Expert 100+
I suppose I should be more clear, in a situation like this I find it to be more robust to add the data through a query containing the values you wish to add instead of operating on the table itself via the data bound form, however linq, you are right, while this solves the problem it is somewhat tangential to the question.
Mar 28 '08 #5
ncsthbell
167 100+
Thanks for all the replies. Unfortunately, I inherited an application already built in which the 'previous' owner create the forms in datasheet view and created them with tables as the record source so there are no 'add or delete record' buttons that I could use to put validation code on. All the validation has to be done on the field or form events. I would not have designed this way myself, however, I am stuck with trying to fix the 'bugs'. I will try some of the suggestions and let you know how it goes.
Again, Thanks!
May 8 '08 #6

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

Similar topics

4
by: Stuart Perryman | last post by:
Hi, I have the following code which works just fine in IE6 but not in Firefox. It is an extract of several table rows each with an individual form. It is generated by php. <form...
0
by: Malcolm Cook | last post by:
I've discovered: Using "File > Print Preview" in a form's datasheet view with a server Filter crashes access after previewing... ....that is, unless ServerFilterByForm has been turned off...
2
by: Simon Pleasants | last post by:
Am something of a newbie at this, so please bear with any stupid questions. I have created a database to track shipments that we import. The information is stored in a table and I have created...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
2
by: Arnie | last post by:
I have searched this NG for datasheet column width posts and have read many of them. None of them seem to address what I would like to do. I'm beginning to think what I want can't be done. Here...
1
by: Elainie | last post by:
I have a main form and in it I have a datasheet subform filtered on surname, I would like the users to select a name in their list on the subform then the data moves up into the main form... Is...
3
by: Robert McEuen | last post by:
Using A2K3, Windows XP I'm handling a many-to-many relationship with a linking table structure as follows (irrelevant fields omitted): tblIssue PK_IssueID (autonumber, primary key) IssueName...
14
by: BASSPU03 | last post by:
(I'm using Access 2003 on a Windows XP O/S.) I've gotta present an update on my database this week--possibly within the next 24 hours. A solution or guidance to this inquiry would really, really...
5
by: ramab | last post by:
hi guys, I can't figure out how to solve this problem. I have got 3 tab pages containing 3 datasheets based only 1 table. i have 3 primary keys in the table.Two primary keys are found in the 3...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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
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...

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.