Tab Control and Field Check on Form (1 Viewer)

fuonge

New member
Local time
Today, 13:09
Joined
Mar 22, 2014
Messages
1
MS ACCESS 2007 VBA CODE BUILDER

I am able to show a MsgBox in VBA code when a Tab is selected with

Private Sub TabCtl34_Change()
If Me.TabCtl34.Value = 1 Then 'First Page
MsgBox "Hi"
End If
End Sub
But I also want to check if the second tab is selected and a field(Name) on the form IS NULL (not on tab), msgbox or cancel event to require Name to be entered before they see the second tab.

When I add in:

Private Sub TabCtl34_Change()
If Me.TabCtl34.Value = 1 AND [FORMS]![FORMNAME]![NAME] IS NULL Then
MsgBox "Hi"
End If
End Sub
It just goes directly to the second tab even if the name is null. How do i write the vba code so it can do what I want?
 

Ranman256

Well-known member
Local time
Today, 16:09
Joined
Apr 9, 2015
Messages
4,337
you dont need the full path in vb code, just the control name. in a query you need full path
check for null is ISNULL( box). In a query THEN you do: [FIELD] is null

Code:
Private Sub TabCtl34_Change()

select TabCtl34.Value
   case 1
     MsgBox "Hi 1st page"

     if isnull([NAME]) then msgbox "null name"

   case 2

end select
 

Users who are viewing this thread

Top Bottom