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

Validation rules

Hello,

I have a form in my database and I have a check box (PO Received) , when it is ticked I would like to make the user enter the PO Number in a text box. I have tried to use the validation rule [PO Received] and with the validation text [Please enter PO number] but this does not seem to work.

Thanks in advance : )
Dec 10 '07 #1
7 1199
hjozinovic
167 100+
Hi Connoly!
Have you tried to use after update event for that check box?
in the after update event you can use code like this:

Expand|Select|Wrap|Line Numbers
  1. If Me.[PO received] = True Then
  2. Me.[PO Number].Visible=True
  3. '(or you can open a new modal form with PO Number control on it for the user to fill it in)
  4.  
  5.  

Hope this helps. I'll be around if you have more questions.
H.
Dec 10 '07 #2
Great I will give it a try and let you know : )

Hi Connoly!
Have you tried to use after update event for that check box?
in the after update event you can use code like this:

Expand|Select|Wrap|Line Numbers
  1. If Me.[PO received] = True Then
  2. Me.[PO Number].Visible=True
  3. '(or you can open a new modal form with PO Number control on it for the user to fill it in)
  4.  
  5.  

Hope this helps. I'll be around if you have more questions.
H.
Dec 11 '07 #3
Hello Hjozinovic,

I used the following as suggested:

Private Sub PO_Received_AfterUpdate()
If Me.[PO received] = True Then
Me.[PO Number].Visible = True
End If
End Sub

But what I want it to do is to force the user to enter a PO Number or it wont let them save the record. i.e. All Records with a PO Received must have a PO number.

Hope this make sense, Cheers
Dec 11 '07 #4
hjozinovic
167 100+
Hi C.

I just tested this code and it run just fine. I believe this is what you need:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2. If Me.[PO received] = True And Me.[PO number] = "" Then
  3. MsgBox "Please enter PO number"
  4.  
  5. DoCmd.CancelEvent
  6. DoCmd.GoToControl "PO number"
  7. End If
  8. End Sub
This code checks the current record before updating it. If PO is checked, and PO number is empty it will cancel the save record event and it will move focus to PO number control for the user to enter the number inside.

Hope it helps...
h.
Dec 11 '07 #5
H,

I most be going mad, have tried the following, but it does not produce the message box if I check PO or not I have tried 'Not Null' instead of "" as well but still not working. Sorry to be a pain, the form is populated with a query will this make a difference or could the problem be with the space in [PO Received].

Expand|Select|Wrap|Line Numbers
  1.  Private Sub Form_BeforeUpdate(Cancel As Integer)
  2. If Me.[PO Received] = True And Me.[PO number] = "" Then
  3. MsgBox "Please enter PO number"
  4. DoCmd.CancelEvent
  5. DoCmd.GoToControl "PO number"
  6. End If
  7. End Sub
  8.  
and also:

Expand|Select|Wrap|Line Numbers
  1.  Private Sub Form_AfterUpdate(Cancel As Integer)
  2. If Me.[PO Received] = True And Me.[PO number] = "" Then
  3. MsgBox "Please enter PO number"
  4. DoCmd.CancelEvent
  5. DoCmd.GoToControl "PO number"
  6. End If
  7. End Sub
  8.  
  9.  
Hi C.

I just tested this code and it run just fine. I believe this is what you need:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2. If Me.[PO received] = True And Me.[PO number] = "" Then
  3. MsgBox "Please enter PO number"
  4.  
  5. DoCmd.CancelEvent
  6. DoCmd.GoToControl "PO number"
  7. End If
  8. End Sub
This code checks the current record before updating it. If PO is checked, and PO number is empty it will cancel the save record event and it will move focus to PO number control for the user to enter the number inside.

Hope it helps...
h.
Dec 11 '07 #6
missinglinq
3,532 Expert 2GB
You had the right idea in checking for Null, just the wrong syntax, I expect:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2.  If Me.[PO Received] = True And IsNull(Me.[PO number]) Then
  3.  MsgBox "Please enter PO number"
  4.  DoCmd.CancelEvent
  5.  DoCmd.GoToControl "PO number"
  6.  End If
  7.  End Sub
  8.  
Please remember to always use Code Tags when posting code.

Welcome to TheScripts!

Linq ;0)>
Dec 11 '07 #7
Hello Linq,

I will make sure I use code tags in the future : )

And we are rocking and rolling with the new code the only problem was it didn't like running the code when updating on the field and said that I needed to save the form before running the 'GoToControl' method. However when I did it on the form itself it worked fine, (another although) although I did have to close the form and display a message saying not saved and that the user would need to go back in and re-enter and inc a PO number. This is not the end of the world as I am chuffed with it at the moment.

Thanks for your input 'A*'


You had the right idea in checking for Null, just the wrong syntax, I expect:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2.  If Me.[PO Received] = True And IsNull(Me.[PO number]) Then
  3.  MsgBox "Please enter PO number"
  4.  DoCmd.CancelEvent
  5.  DoCmd.GoToControl "PO number"
  6.  End If
  7.  End Sub
  8.  
Please remember to always use Code Tags when posting code.

Welcome to TheScripts!

Linq ;0)>
Dec 11 '07 #8

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

Similar topics

21
by: Stefan Richter | last post by:
Hi, after coding for days on stupid form validations - Like: strings (min / max length), numbers(min / max value), money(min / max value), postcodes(min / max value), telefon numbers, email...
1
by: Mike | last post by:
Note: My XML experience to date has (unfortunately) been limited to reading and thinking, rather than implementation. Anyway, I am in the process of trying to figure out the most efficient way...
4
by: Mike | last post by:
Related to another topic I just posted, I wanted to discuss ways to optimize the validation of very large (>100MB) XML documents. First, I have no idea if something like this already exists; it...
2
by: wumingshi | last post by:
Hi, When validating an XML instance, sometimes the schema is not enough to expression the validation rules. Additional validation rules may be expressed in an application-specific way. For...
67
by: Scott Meyers | last post by:
I have a web site that, due to maintenance by several people, some of whom are fairly clueless about HTML and CSS, etc. (notably me), has gotten to the point where I'm pretty sure it's suffering...
3
by: Bob Alston | last post by:
I have a routine to copy data to new versions of my app via insert into sql statements. Unfortunately, due to evolution of my app, sometimes the new version has more restrictive editing than an...
0
by: info | last post by:
Hi, Is it possible to include in the Schema validation file, every custom error message for each validation rules? This mean, in the same xsd file we can have the validation rules (patterns)...
5
by: peev2001 | last post by:
Hi every body, I have some basic queries regarding validation of data entered by different users: I have a form from where the users are going to enter the data. I have tried to put some...
10
by: gweasel | last post by:
What is the best way to apply a Validation Rule - or rather, where is the best place to put it? Is there an advantage to putting it on the field in the table vs setting the validation rule on the...
7
ak1dnar
by: ak1dnar | last post by:
Hi, I got this scripts from this URL There is Error when i submit the form. Line: 54 Error: 'document.getElementbyID(....)' is null or not an object What is this error. Complete 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...
0
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...

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.