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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
"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
|
|||
|
|||
"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
|
|||
|
|||
"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
|
|||
|
|||
"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
|
|||
|
|||
"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
|
|||
|
|||
"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 | |
|
|