473,387 Members | 1,504 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.

Beforeupdate call function to check text boxes

I want to call a function which does this when the next record button
is pressed (calling it from before update)
if textboxes are empty then
Message box you must fill text box
else
comit the record and move to next record (How do you do this bit?)

At the moment all my if statement does is check the textboxes i need to
know what to do after the else. Otherwise the form just sites there
when the textbox has a value in it.

Cheers!

Nov 13 '05 #1
9 3347
<si************@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
I want to call a function which does this when the next record button
is pressed (calling it from before update)

Why didn't you answer the question I asked in your other thread and why
start a new one on the same subject?
Nov 13 '05 #2
I did answer

Nov 13 '05 #3
Im new to both access and newsgroups.

I thought that this question was very simple and that it must be a
common thing to do in access.

All i am trying to do is check the form save it and move onto the next.

I could put a button on the form to check the code and then get the
users to press next but i want to do it to all be done in one click.

Please help someone. :(

Nov 13 '05 #4
si************@gmail.com wrote:
Im new to both access and newsgroups.

I thought that this question was very simple and that it must be a
common thing to do in access.

All i am trying to do is check the form save it and move onto the
next.

I could put a button on the form to check the code and then get the
users to press next but i want to do it to all be done in one click.

Please help someone. :(


So regardless of whether your "check" passes or fails you still want to
navigate to a different record? What exactly should happen to the ones that
fail?

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #5
My code for a check on a text boxe is as folows
If IsNull(Form_form1.PaymentMethod) Then
MsgBox "Payment Method is required", vbOKOnly, "Required Field"
Form_form1.PaymentMethod.SetFocus
Exit Function

So if its empty i output a message to the user.

Nov 13 '05 #6
si************@gmail.com wrote:
My code for a check on a text boxe is as folows
If IsNull(Form_form1.PaymentMethod) Then
MsgBox "Payment Method is required", vbOKOnly, "Required Field"
Form_form1.PaymentMethod.SetFocus
Exit Function

So if its empty i output a message to the user.


Validation code should be run in the BeforeUpdate event and then you set the
Cancel argument to True when the validation fails. Setting Cancel to True
cancels the update. If the update was triggered by the user attmepting to
navigate or close the form then those actions are cancelled as well. If the
validation passes then the close or the navigate that initiated the update
works without the user even being aware that the validaton code was run.

Where are you running your code?

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com

Nov 13 '05 #7
The code is stored in a module and a macro is called in beforeupdate to
run a function in the module.

Is the syntax just cancel = True ?

But i still dont know how to move to the next form.

It just stays on the currwent form if its validated.

Nov 13 '05 #8
si************@gmail.com wrote:
The code is stored in a module and a macro is called in beforeupdate
to run a function in the module.

Is the syntax just cancel = True ?

But i still dont know how to move to the next form.

It just stays on the currwent form if its validated.


All you need is for your validation code to return True or False (make it a
function). Then in your BeforeUpdate event...

Cancel = MyFunction()
or
Cancel = Not MyFunction()

....depending on whether your function returns True upon validation failing
or upon validation passing.

Do NOT try to make your validation code also navigate to another record.
You let the user navigate by normal means and that will trigger BeforeUpdate
and if your Function does not cause BeforeUpdate to be cancelled then the
navigation will happen.

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #9
Thankyou!

That worked! Nice one!!!

Nov 13 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: J. Hall | last post by:
Hi dudes, Got a simple webpage, with three numeric text input boxes, the idea being that the user is asked to insert percentages of their business around the world... UK, Europe, Other ...
12
by: Susan Cranford | last post by:
Please forgive, I have looked at so much info I can't figure out how to put it together even though I know it must be fairly simple. I have an array of input text boxes (txtDOBn) where n is...
4
by: William Wisnieski | last post by:
Hello Everyone, Access 2000 I have a form with multiple pages on it. There is one text field on the third page of the form that I need the user to complete before leaving the form or moving...
15
by: simonmarkjones | last post by:
I want to validate my form using a BeforeUpdate event. However now that i call my code with a beforeupdate it wont let me go to next or previous records. What code should i put in o allow me...
6
by: tlyczko | last post by:
I have a BeforeUpdate where I need to ensure that no matter what, the first four fields on the form (one text box, 3 combo box lists) have data entered in them before the user closes the form or...
4
by: jj6849 | last post by:
I have been using the dom to add a row to my form for awhile now, but now I need to do some validation to make sure certain check boxes aren't checked with other check boxes. Now of course it works...
5
by: Lee | last post by:
(I also posted this query in Microsoft.Public.DotNet.Framework yesterday, but since I have received no responses, I am posting it here too.) Using Windows XP with all updates applied and Visual...
7
by: john.cole | last post by:
I have searched all the groups I can, and I still haven't been able to come up the solution I need. I have the following problem. In my form named sbfrmSpoolList, I am entering a job, spool and...
11
by: ChipR | last post by:
I have a generic AfterUpdate function applied to my 14 text boxes in a continuous subform, but I can't figure out the syntax to do BeforeUpdate with Cancel. Is this even possible? Private Sub...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
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.