473,698 Members | 2,808 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3380
<si************ @gmail.com> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.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_for m1.PaymentMetho d) Then
MsgBox "Payment Method is required", vbOKOnly, "Required Field"
Form_form1.Paym entMethod.SetFo cus
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_for m1.PaymentMetho d) Then
MsgBox "Payment Method is required", vbOKOnly, "Required Field"
Form_form1.Paym entMethod.SetFo cus
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
1766
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 Obviously this mustn't exceed 100% and so I OnChange I simply want to check that all three boxes have a value, and if so sum them up and alert the user
12
7001
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 created at load. On the onchange event I want to calc the age and show in adjacent input text boxes that are readonly and also arrays (an age calced for each DOB entered). I was going to use the datediff function in vbscript to do the calc. Can...
4
4039
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 to the next record. So, in the BeforeUpdate event of the form itself I have the following code:
15
4810
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 to do thi??
6
7595
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 before the user moves off the form to a subform on the main form, regardless of whether the end user even put focus to any of the four form fields. (It is easy to know if all 4 fields have values, but not if less than four fields have values.) ...
4
17139
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 with the first row, but after I add a row, the Function does not work (no runtime error or anything). So first is my Function do the validation, second is my code for adding new row (this is where I'm having trouble, maybe with the setAttribute??),...
5
1634
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 Studio 2.0. I am trying to develop some common error-handling of Windows API invocations that fail and am using MessageBeep as the API to test with. Given 1) the following Imports statement:
7
6857
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 revision number. My table is indexed properly to not allow duplicates, but I would like teh user to be notified that they are typing a duplicate via a message box, then I woulld the update of the record to be cancelled. I have tried the...
11
3465
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 Form_Load() Dim ctl As Control For Each ctl In Me.Controls If Left(ctl.Name, 3) = "Day" Then '??? ctl.BeforeUpdate = "=CheckDay(""" & ctl.Name & """)" ctl.AfterUpdate = "=FixDay(""" & ctl.Name & """)" End If Next ctl
0
8603
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9026
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2328
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.