R
Rob H
Hi I am using the following code to try and validate my
form before quitting the application.
I require cbocycle, cbometer, cbosite & txtreading to all
be filled in if the db is quit so the record is only
saved on exit if there is a full record.
There is one exception to this where if all of the above
fields are blank I would like to exit the db as the
record is blank. I have tried to use the elseif
statement to do this but I cant get them to work
together. Is there an empty state I can refer to or does
anyone know how to correct what I have written below?
Thanks
Rob
If Len(Me.[cbocycle] & vbNullString) = 0 Or Len(Me.
[cbometer] & vbNullString) = 0 Or Len(Me.[cbosite] &
vbNullString) = 0 Or Len(Me.[txtreading] & vbNullString)
= 0 Then
MsgBox ("To Quit the application you must clear the form
first or add a complete record to be saved upon exit"),
vbInformation, "Yorkshire Water"
Exit Sub
ElseIf Len(Me.[cbocycle] & vbNullString) = 0 And Len(Me.
[cbometer] & vbNullString) = 0 And Len(Me.[cbosite] &
vbNullString) = 0 And Len(Me.[txtreading] & vbNullString)
= 0 Then
DoCmd.Quit
Else
DoCmd.Quit
End If
form before quitting the application.
I require cbocycle, cbometer, cbosite & txtreading to all
be filled in if the db is quit so the record is only
saved on exit if there is a full record.
There is one exception to this where if all of the above
fields are blank I would like to exit the db as the
record is blank. I have tried to use the elseif
statement to do this but I cant get them to work
together. Is there an empty state I can refer to or does
anyone know how to correct what I have written below?
Thanks
Rob
If Len(Me.[cbocycle] & vbNullString) = 0 Or Len(Me.
[cbometer] & vbNullString) = 0 Or Len(Me.[cbosite] &
vbNullString) = 0 Or Len(Me.[txtreading] & vbNullString)
= 0 Then
MsgBox ("To Quit the application you must clear the form
first or add a complete record to be saved upon exit"),
vbInformation, "Yorkshire Water"
Exit Sub
ElseIf Len(Me.[cbocycle] & vbNullString) = 0 And Len(Me.
[cbometer] & vbNullString) = 0 And Len(Me.[cbosite] &
vbNullString) = 0 And Len(Me.[txtreading] & vbNullString)
= 0 Then
DoCmd.Quit
Else
DoCmd.Quit
End If