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  

"Before update" question



 
 
Thread Tools Display Modes
  #1  
Old July 11th, 2007, 11:09 AM posted to microsoft.public.access.forms
Bob Quintal
external usenet poster
 
Posts: 939
Default "Before update" question

=?Utf-8?B?c2N1YmFkaXZlcg==?=
wrote in
:

I have three combo boxes in a form

Act_Dept
Act_Subd
Act_User

The 2nd and 3rd have the following code:

If IsNull(Me!Act_Subd) Then
MsgBox "You must fill in the subdepartment",
vbCritical Cancel = True
Me!Act_Subd.SetFocus
End If


If IsNull(Me!Act_User) Then
MsgBox "You must fill in the user name", vbCritical
Cancel = True
End If

Now I only want these codes to fire when Act_Dept is not null.
I have tried added an extra line but it doesn't seem to work.

If Me!Act_Dept Null and IsNull(Me!Act_Subd) Then
MsgBox "You must fill in the subdepartment",
vbCritical Cancel = True
Me!Act_Subd.SetFocus
End If

Cheers


If MeAct_dept! null will not work
Replace it with
If (Not isnull(Me!Act_Dept)) AND isnull)Me!Act_Subd_ then

--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

  #2  
Old July 11th, 2007, 11:50 AM posted to microsoft.public.access.forms
scubadiver
external usenet poster
 
Posts: 1,673
Default "Before update" question

I have three combo boxes in a form

Act_Dept
Act_Subd
Act_User

The 2nd and 3rd have the following code:

If IsNull(Me!Act_Subd) Then
MsgBox "You must fill in the subdepartment", vbCritical
Cancel = True
Me!Act_Subd.SetFocus
End If


If IsNull(Me!Act_User) Then
MsgBox "You must fill in the user name", vbCritical
Cancel = True
End If

Now I only want these codes to fire when Act_Dept is not null. I have tried
added an extra line but it doesn't seem to work.

If Me!Act_Dept Null and IsNull(Me!Act_Subd) Then
MsgBox "You must fill in the subdepartment", vbCritical
Cancel = True
Me!Act_Subd.SetFocus
End If

Cheers
  #3  
Old July 11th, 2007, 12:18 PM posted to microsoft.public.access.forms
Rick Brandt
external usenet poster
 
Posts: 4,354
Default "Before update" question

scubadiver wrote:
I have three combo boxes in a form

Act_Dept
Act_Subd
Act_User

The 2nd and 3rd have the following code:

If IsNull(Me!Act_Subd) Then
MsgBox "You must fill in the subdepartment", vbCritical
Cancel = True
Me!Act_Subd.SetFocus
End If


If IsNull(Me!Act_User) Then
MsgBox "You must fill in the user name", vbCritical
Cancel = True
End If

Now I only want these codes to fire when Act_Dept is not null. I have
tried added an extra line but it doesn't seem to work.

If Me!Act_Dept Null and IsNull(Me!Act_Subd) Then
MsgBox "You must fill in the subdepartment", vbCritical
Cancel = True
Me!Act_Subd.SetFocus
End If

Cheers


You cannot use = or to test for null. You have to use...

IsNull(...)
or
Not IsNull(...)

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


  #4  
Old July 11th, 2007, 12:31 PM posted to microsoft.public.access.forms
BruceM[_2_]
external usenet poster
 
Posts: 1,763
Default "Before update" question

Try:
If Not IsNull (Me.Act_Dept) and IsNull(Me.Act_Subd) Then
etc.

You didn't say in which event the code occurs, but if the user never enters
the combo box its code won't have a chance to run. If you programatically
send the user to the combo box, and the user then exits the combo box
without making a selection, the code won't run either. The Form's Before
Update event is generally a good place to perform validation, although it
could be in the Change or Enter event of another control.

"scubadiver" wrote in message
...
I have three combo boxes in a form

Act_Dept
Act_Subd
Act_User

The 2nd and 3rd have the following code:

If IsNull(Me!Act_Subd) Then
MsgBox "You must fill in the subdepartment", vbCritical
Cancel = True
Me!Act_Subd.SetFocus
End If


If IsNull(Me!Act_User) Then
MsgBox "You must fill in the user name", vbCritical
Cancel = True
End If

Now I only want these codes to fire when Act_Dept is not null. I have
tried
added an extra line but it doesn't seem to work.

If Me!Act_Dept Null and IsNull(Me!Act_Subd) Then
MsgBox "You must fill in the subdepartment", vbCritical
Cancel = True
Me!Act_Subd.SetFocus
End If

Cheers



  #5  
Old July 11th, 2007, 01:06 PM posted to microsoft.public.access.forms
scubadiver
external usenet poster
 
Posts: 1,673
Default "Before update" question


Thanks




"Rick Brandt" wrote:

scubadiver wrote:
I have three combo boxes in a form

Act_Dept
Act_Subd
Act_User

The 2nd and 3rd have the following code:

If IsNull(Me!Act_Subd) Then
MsgBox "You must fill in the subdepartment", vbCritical
Cancel = True
Me!Act_Subd.SetFocus
End If


If IsNull(Me!Act_User) Then
MsgBox "You must fill in the user name", vbCritical
Cancel = True
End If

Now I only want these codes to fire when Act_Dept is not null. I have
tried added an extra line but it doesn't seem to work.

If Me!Act_Dept Null and IsNull(Me!Act_Subd) Then
MsgBox "You must fill in the subdepartment", vbCritical
Cancel = True
Me!Act_Subd.SetFocus
End If

Cheers


You cannot use = or to test for null. You have to use...

IsNull(...)
or
Not IsNull(...)

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com



  #6  
Old July 11th, 2007, 03:38 PM posted to microsoft.public.access.forms
Klatuu
external usenet poster
 
Posts: 7,074
Default "Before update" question

Check your syntax:
If (Not isnull(Me!Act_Dept)) AND isnull)Me!Act_Subd_ then
If Not IsNull(Me.Act_Dept) And IsNull(Me.Act_Subd) Then
--
Dave Hargis, Microsoft Access MVP


"Bob Quintal" wrote:

=?Utf-8?B?c2N1YmFkaXZlcg==?=
wrote in
:

I have three combo boxes in a form

Act_Dept
Act_Subd
Act_User

The 2nd and 3rd have the following code:

If IsNull(Me!Act_Subd) Then
MsgBox "You must fill in the subdepartment",
vbCritical Cancel = True
Me!Act_Subd.SetFocus
End If


If IsNull(Me!Act_User) Then
MsgBox "You must fill in the user name", vbCritical
Cancel = True
End If

Now I only want these codes to fire when Act_Dept is not null.
I have tried added an extra line but it doesn't seem to work.

If Me!Act_Dept Null and IsNull(Me!Act_Subd) Then
MsgBox "You must fill in the subdepartment",
vbCritical Cancel = True
Me!Act_Subd.SetFocus
End If

Cheers


If MeAct_dept! null will not work
Replace it with
If (Not isnull(Me!Act_Dept)) AND isnull)Me!Act_Subd_ then

--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com


 




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 11:51 AM.


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