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  

Form Validation where 1 field depends on another fields value



 
 
Thread Tools Display Modes
  #1  
Old October 24th, 2009, 03:34 AM posted to microsoft.public.access.forms
Nurse Nancy
external usenet poster
 
Posts: 67
Default Form Validation where 1 field depends on another fields value

Hi
I have a form where I have 2 fields
AgencyDirectCB - this has a valuelist with Agency or Direct
AgencyCB - This is a combobox from a query of the Agency Table
DirectContactID - this will contain the Direct ContactID

I would like to do the following...

If the user selects Agency, in the AgencyDirectCB, then they must select an
Agency from AgencyCB (it can not be null) and
The DIrectContactID must be null, or not enabled,,,, (but what if there was
already a contact in there, and user is changing from Direct to Agency, it
would need it to be nulled out)

If the User select Direct, then the AgencyCB must be null and
DirectContactID must not be null

Does anyone know how I would do this,, or have a similar example they could
send me,, thanks so much



--
Nancy
  #2  
Old October 24th, 2009, 04:59 AM posted to microsoft.public.access.forms
Jeanette Cunningham
external usenet poster
 
Posts: 2,190
Default Form Validation where 1 field depends on another fields value

Hi Nurse Nancy,

Here are some sample codes - air code, untested.

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Len(Me.AgencyDiretCB) 0 Then
If IsNull(Me.AgencyCB) Then
Cancel = True
MsgBox "You must select an agency"
End If
End If
End Sub

Private Sub AgencyDirectCB_AfterUpdate()
If Len(Me.AgencyDirectCB) 0 Then
Me.DIrectContactID = Null
End If
End Sub


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


"Nurse Nancy" wrote in message
...
Hi
I have a form where I have 2 fields
AgencyDirectCB - this has a valuelist with Agency or Direct
AgencyCB - This is a combobox from a query of the Agency Table
DirectContactID - this will contain the Direct ContactID

I would like to do the following...

If the user selects Agency, in the AgencyDirectCB, then they must select
an
Agency from AgencyCB (it can not be null) and
The DIrectContactID must be null, or not enabled,,,, (but what if there
was
already a contact in there, and user is changing from Direct to Agency, it
would need it to be nulled out)

If the User select Direct, then the AgencyCB must be null and
DirectContactID must not be null

Does anyone know how I would do this,, or have a similar example they
could
send me,, thanks so much



--
Nancy



 




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 08:18 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.