A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Required Field Code



 
 
Thread Tools Display Modes
  #1  
Old July 26th, 2007, 03:53 AM posted to microsoft.public.access.forms
3rookerbar
external usenet poster
 
Posts: 1
Default Required Field Code

I am trying to create code that will make a field required depending on the
value of another field. "Priorpap" is a required field and may contain two
possible values, either 0 or 1. If "priorpap" is equal to 1 then "ppdate"
needs to be a required field. If "priorpap" is equal to 0 then "ppdate" is
not required. Any help would be appreciated.

  #2  
Old July 26th, 2007, 07:56 AM posted to microsoft.public.access.forms
scubadiver
external usenet poster
 
Posts: 1,673
Default Required Field Code


Make "PriorPap" default to zero and "ppdate" an optional field.

Put this code in the "before update" event of the form

If me.priorpap = 1 Then
MsgBox "ppdate is now required", vbCritical
Cancel = True
Me!ppdate.SetFocus
End If

I think that should work.

--
www.ae911truth.org



"3rookerbar" wrote:

I am trying to create code that will make a field required depending on the
value of another field. "Priorpap" is a required field and may contain two
possible values, either 0 or 1. If "priorpap" is equal to 1 then "ppdate"
needs to be a required field. If "priorpap" is equal to 0 then "ppdate" is
not required. Any help would be appreciated.


  #3  
Old July 26th, 2007, 12:30 PM posted to microsoft.public.access.forms
missinglinq via AccessMonster.com
external usenet poster
 
Posts: 545
Default Required Field Code

If me.priorpap = 1 Then
MsgBox "ppdate is now required", vbCritical
Cancel = True
Me!ppdate.SetFocus
End If

And what if ppdate has already been filled in? Won't the above code still
fire? Maybe something like

If me.priorpap = 1 and IsNull(Me.ppdate) Then
MsgBox "ppdate is now required", vbCritical
Cancel = True
Me!ppdate.SetFocus
End If

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200707/1

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:56 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.