to have null fields on a customised msgbox

soundsfishy

Registered User.
Local time
Tomorrow, 00:11
Joined
Sep 25, 2002
Messages
174
I need a piece of code that alerts users after they have click the save button that some field havent been field in. The fields are not mandatory. I need the null fields displayed in the message

What im after is something like this;

Private Sub btnSave_Click()
Dim strOfficer As String
Dim strUnitSize As String
Dim strNationality As String

If IsNull.....(strOfficer) Or IsNull(strUnitSize) etc then

MsgBox" The following have not been entered. Is this correct?", vbYesNo & vbNewLine & _

strOfficer
strUnitSize
srtNationality

End If
End Sub

I having trouble tring to understand how the Dim.
 
Last edited:
Dim is for declaring variables in your module...

You want to check values on the form, no need to 'Dim' them..

dim strNullFields as string
myNullFields = ""
if isnull(me.txtField1) then
strNullFields = strNullFields & "Field1" & vbnewline
endif
if isnull(me.txtField2) then
strnullfields = strnullfields & "Field2" & vbnewline
endif
msgbox "The following have not been entered. Is this correct?", vbYesNo & vbNewLine & strnullfields

That should give you an idea on how to do what you want...

Regards

The Mailman
 
Thanks for that MailMan!! Awesome.

I dont suppose you delivered mail to my house? my son has blonde hair and I have dark hair!! mmm ..hehehe
 
Im getting a run-time 13 error
type mismatch

can you check to see what im doing wrong.


Private Sub Command1048_Click()
Dim strNullFields As String
strNullFields = ""
If IsNull(Me.txtOfficerName) Then
strNullFields = strNullFields & "OfficerName" & vbNewLine
End If
If IsNull(Me.cboVisaClass) Then
strNullFields = strNullFields & "VisaClass" & vbNewLine
End If
MsgBox "The following have not been entered. Is this correct?", vbYesNo & vbNewLine & "strNullFields"
End Sub


OfficerName & VisaClass are my control source names and txtOfficer &cboVisaClass are my control names.
 
Your message box line is incorrect.

Try:

MsgBox "The following have not been entered. Is this correct?"& vbNewLine & strNullFields, vbYesNo



You will still need to add actions for the Yes / No input from the user.

Cheers

Brad.
 
Thanks Brad!

Yep that worked. Much better now.

Actually it was that line that give me grief.

I think I need to insert and "Else" somewhere. I dont want the messsage to pop up if the field are "not" Null . In need it to save the new record.


cheers champ!
 
Last edited:

Users who are viewing this thread

Back
Top Bottom