By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 936 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

Beforeupdate call function to check text boxes

P: n/a
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
Share this Question
Share on Google+
9 Replies


P: n/a
<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

P: n/a
I did answer

Nov 13 '05 #3

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
Thankyou!

That worked! Nice one!!!

Nov 13 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.