Empty textbox

endri81

Registered User.
Local time
Today, 11:18
Joined
Jul 5, 2010
Messages
121
I have tabbed form.
I need some warning text to be shown if some fields are left empty when passing from page to page.How can this be coded?
 
...I need some warning text to be shown if some fields are left empty when passing from page to page.
Are you speaking of controls on multiple pages that are all bound to a single RecordSource, or are you talking about controls residing on various subforms that reside on these pages? It will make a difference in how you handle this.

Also, do you just want a warning message to come up or do you want to prevent them from leaving the page until the fields are populated?

Linq ;0)>
 
No single controls residing on pages
 
OK, next question: Will the users only be moving from one page to another, within the Tabbed Control, or can they move off of the Tabbed Control all together and go to a control that doesn't reside on any of them?

If the former this can probably be done, but if the latter is the case I can think of no real way to tell when they leave the it, as Tabbed Controls don't have LostFocus or Exit events. If this is the case I suspect you'd have to use standard validation code in the Form_BeforeUpdate event to check for Nulls in the controls. This, of course, would only occur when the record is being saved, not actually when moving from page to page.
 
User will move from one page to another inside the tabbed control
 
You COULD save the tab control's page value to a form variable
Code:
Private lngTab As Long

when you open the form and then in the tab control's On Change event you can use something like this:
Code:
Dim blnNotFilled As Boolean
 
If lngTab <> Me.MyTabControl Then
   Select Case lngTab
       Case 0
            If Len(Me.TextBoxOnTab1 & "") = 0 OR _
            Len(Me.cboMyCombo & "") = 0 OR _
            Len(Me.SomeOtherControl & "") = 0 Then
                 blnNotFilled
            End If
 
      Case 1
 
            If Len(Me.TextBoxOnTab2 & "") = 0 OR _
            Len(Me.cboMyCombo2 & "") = 0 OR _
            Len(Me.SomeOtherControl2 & "") = 0 Then
                 blnNotFilled
            End If
 
    Case 2
 
            If Len(Me.TextBoxOnTab3 & "") = 0 OR _
            Len(Me.cboMyCombo3 & "") = 0 OR _
            Len(Me.SomeOtherControl3 & "") = 0 Then
                 blnNotFilled
            End If
 
   End Select
 
   If blnNotFilled Then
      MsgBox "You have not yet filled out all fields for this page.", vbInformation
      Me.MyTabControl = lngTab
   Else
      lngTab = Me.MyTabControl
   End If
End If

So, in the ON Change event it checks to see if the tab you are selecting is the same as the currently set one in the form variable. If it is it doesn't do anything, if it isn't then it checks to see which tab you are on using the select case and then checks whatever control checks you have put in place. We use a blnNotFilled flag so we don't need to have a ton of message box code in there and also so we can set the page back in one location in the code.

I have not tested this but theoretically it should work.
 
Thanks for jumping in, Bob! That's along the lines that I was thinking, but something came up here and haven't had time to knock out any code. :p
 

Users who are viewing this thread

Back
Top Bottom