Check for entry - Any comments? (1 Viewer)

Status
Not open for further replies.

reclusivemonkey

Registered User.
Local time
Today, 00:56
Joined
Oct 5, 2004
Messages
749
Just going through a DB today and I was struck by an idea... I was writing code to check fields for data, and if they were empty I was prompting the user. Now I usually try to fill in the status bar text and control tip text with some like "Please select a month" or whatever. So, I came up with this;

Code:
Public Function CheckForEntry(ByRef myControl As Variant)
    
    ' Why write a check for an entry in each control when we can function it?
    If IsNull(myControl) Then
            If IsNull(myControl.ControlTipText) Then
                    MsgBox "Please check you have completed all the necessary fields."
                    DoCmd.GoToControl myControl.Name
                Else
                    MsgBox myControl.ControlTipText
                    DoCmd.GoToControl myControl.Name
                    End
            End If
        Else
    End If
    
End Function

Now of course if you don't populate the ControlTipText or the StatusBarText then its not much good, but I was quite pleased with myself. I am sure someone can write this to use an array and make it generally more useful...
 

ozinm

Human Coffee Siphon
Local time
Today, 00:56
Joined
Jul 10, 2003
Messages
121
Cool.
you could also use the same sort of thing to do a check and report before saving the record.
All you'd need to do is something like setting the Tag for each control that has to be filled in to TRUE.
You could then get the code to loop through all the items in Me.Form.Controls checking the Tag and Value of the control.
 
Status
Not open for further replies.

Users who are viewing this thread

Top Bottom