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

How to verify data before closing record?

Yes, I know there must be a guide out there somewhere that answers this question quickly, but then again most of them answer a question slightly different than the one I want.

Basically, I have a form, which is just a recordset of a few thousand entries. When ever I leave the current record, I want to perform a check of validity on some of my fields. This is not the same as wanting to perform the check "After Update", that's too frequent. Also not the same as "On Close" or "On Unload", since those apply to the form, not the record.

Where do I need to put this code?
Dec 7 '06 #1
6 4184
NeoPa
32,556 Expert Mod 16PB
You need to put it in the Form_BeforeUpdate event.
Not in any events for the controls but only for the form itself.
If validation fails then just set Cancel=True and the update won't happen.
Dec 7 '06 #2
I thought of that one. The problem I have with that is that this form is tabbed. The field I want to verify is not on the main tab. In fact, in some cases there is a subform contained in the tab which contains the field I want to verify(heh, figure that one out). Anyway, when the user creates a new record, the field I wish to verify is empty, but when the user tries to get at the tab where the special field is, the form automatically attempts to perform an Update. Since the special field is not yet populated, the verification will fail, and the user will get an error message. It's true that the user can enter the information immediately after, but this is messy and not really acceptable and I would prefer it only to verify on the final update, before the record is closed.....Make any sense?
Dec 8 '06 #3
NeoPa
32,556 Expert Mod 16PB
It makes sense (sort of - I'm surprised that an update is performed on the main form dataset).
This is not an insurmountable problem though. You can surely do a test to determine if this update is caused by just selecting the form. If it is then bypass the verification code.
Dec 8 '06 #4
MSeda
159 Expert 100+
I've had similar problems using tab controls and really the easiest way around records updating when moving between subforms is to use unbound forms and then insert all data when the user clicks an enter button via an SQL statement that pulls all of the fields from the form. And of course you could run any number of validations prior to that.
Dec 8 '06 #5
NeoPa
32,556 Expert Mod 16PB
I've had similar problems using tab controls and really the easiest way around records updating when moving between subforms is to use unbound forms and then insert all data when the user clicks an enter button via an SQL statement that pulls all of the fields from the form. And of course you could run any number of validations prior to that.
That's a good solution but becomes more impractical the more complicated the subforms are.
With this in mind, it's probably worth getting to grips with a method which works in all circumstance.
It's a shame that MS don't provide an option to disable that behaviour though :(.
Dec 8 '06 #6
In the end I solved it by putting all of the required fields in the default tab of my form. In this way I don't have to worry about BeforeUpdate being called automatically. The validation still fails all the time, but at least the error is intuitive to the user(at least I hope it is).
Dec 11 '06 #7

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

Similar topics

1
by: Deborah V. Gardner | last post by:
I have a form with a data source consisting of two linked tables, tblComplaints and tblViolations. When I click on a checkbox to add a violation related to the Complaint, I have used the AddNew...
1
by: John | last post by:
My data has 10 accounts. Two forms are opened simultaneously. Form1 is unbound and displays three records: Account Quantity 101 17 104 25 107 ...
2
by: ArmsTom | last post by:
I have it set up like this right now: <record id="1"> <record data1> ... <record data9> </record> There are a couple hundred records and, often times, data overlaps. So, record data in one...
0
by: jpr | last post by:
Hello, I need some help. I have a form named MASTER based on a table also called MASTER. A control of my form in names SSN which stores the client SSN. On the same form I have placed a subform...
3
by: jpr | last post by:
Hello, I have a form on which I have a cmdbutton to copy a couple of fields into another table (MASTER) using the SSN on the active form as criteria. In the active form (based on a tables...
8
by: SBC News Groups | last post by:
I have a field on a form that when a user enters a number, I want to verify that the number is already in another table. For example: If a user enters 100 in the control Bidder, I want to check...
3
by: Darin | last post by:
I have a problem I just can't figure out. I have a form with a subform, and the recordsource of the subform has criteria based on some unbound fields in the parent form so that data in the parent...
6
Frinavale
by: Frinavale | last post by:
Apparently I have a lot of questions today regarding JavaScript security. I've implemented a JavaScript Object that intercepts page submits (postbacks) and then displays a UI prompting the user...
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...
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...
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
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...

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.