UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Check If Combo Is Null, 2010    
 
   
dzoker
post Jun 17 2016, 01:58 PM
Post#1



Posts: 371
Joined: 12-February 14



Hi all,

I have a subform with datasheet view with a combo and a date text box for each record. I want to not allow the user to go to the next record if only combobox is filled or the Date text box is filled. I tried this but it is not working:

CODE
Private Sub DateDispo_LostFocus()
On Error GoTo DateDispo_LostFocus

If IsNull(Me.DispoID) Then
Cancel = True
Else

    MsgBox "Please fill in the Dispo Date field!"

Me.DispoID.SetFocus
Me.DateDispo.SetFocus

End If

Exit_DateDispo_LostFocus:
Exit Sub

DateDispo_LostFocus:
MsgBox "There has been an Error. The Error number is: " & Err.Number & vbCrLf & "The Error Description: " & Err.Description

Resume Exit_DateDispo_LostFocus:

End Sub


Thank you
Go to the top of the page
 
theDBguy
post Jun 17 2016, 02:13 PM
Post#2


Access Wiki and Forums Moderator
Posts: 71,239
Joined: 19-June 07
From: SunnySandyEggo


I would try using the Form's BeforeUpdate event. Hope it helps...
Go to the top of the page
 
dzoker
post Jun 17 2016, 02:27 PM
Post#3



Posts: 371
Joined: 12-February 14



theDBguy,

Thank you. I think I came up with the solution!? Any comments?

CODE
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Not IsNull(Me.DispoID) And IsNull(Me.DispoDate) Then
MsgBox "Date must be filled"

Cancel = True

ElseIf IsNull(Me.DispoID) And Not IsNull(Me.DispoDate) Then
MsgBox "Dispo must be selected"

Cancel = True

Else

End Sub


Thank you
Go to the top of the page
 
theDBguy
post Jun 17 2016, 02:33 PM
Post#4


Access Wiki and Forums Moderator
Posts: 71,239
Joined: 19-June 07
From: SunnySandyEggo


Hi. Glad to hear you got it working.
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    18th December 2017 - 03:19 PM