Prevent form from closing

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all i am trying to prevent a form from closing by checking for zero length
in the before update

my msg comes up "you must enter Cable Type"

but the form closes i have tried going to the control but it seems the form
has closed and new msg says there is no control named" Cable Type"
i have Cancel=True but the form still closes


If Len(Me.CableType & "") = 0 Then
GoTo NoCableType
Else
MsgBox "Length of CableType is [" & Len(Me.CableType & "") & "]" &
vbCrLf & _
"...and contains [" & Me.CableType & "]"
End If

ExitHere:
Exit Sub

NoCableType:
MsgBox "Please Enter a Cable Type", vbOKOnly
Cancel = True
GoTo ExitHere
End Sub
 
Arnie said:
Hi all i am trying to prevent a form from closing by checking for zero
length
in the before update

my msg comes up "you must enter Cable Type"

but the form closes i have tried going to the control but it seems the
form
has closed and new msg says there is no control named" Cable Type"
i have Cancel=True but the form still closes


If Len(Me.CableType & "") = 0 Then
GoTo NoCableType
Else
MsgBox "Length of CableType is [" & Len(Me.CableType & "") & "]" &
vbCrLf & _
"...and contains [" & Me.CableType & "]"
End If

ExitHere:
Exit Sub

NoCableType:
MsgBox "Please Enter a Cable Type", vbOKOnly
Cancel = True
GoTo ExitHere
End Sub

Which event is this code in?

Keith.
 
Before update but i have tried onclose as well same thing happens

Keith Wilby said:
Arnie said:
Hi all i am trying to prevent a form from closing by checking for zero
length
in the before update

my msg comes up "you must enter Cable Type"

but the form closes i have tried going to the control but it seems the
form
has closed and new msg says there is no control named" Cable Type"
i have Cancel=True but the form still closes


If Len(Me.CableType & "") = 0 Then
GoTo NoCableType
Else
MsgBox "Length of CableType is [" & Len(Me.CableType & "") & "]" &
vbCrLf & _
"...and contains [" & Me.CableType & "]"
End If

ExitHere:
Exit Sub

NoCableType:
MsgBox "Please Enter a Cable Type", vbOKOnly
Cancel = True
GoTo ExitHere
End Sub

Which event is this code in?

Keith.
 
seems to work but i also get "The Microsoft Jet database engine could not
find the object". Make sure the object exists and that you spell its name and
the path name correctly"

the form does stay open but that appears between any of the msgbox i call if
there is no data

Ta
Arnie
 
Arnie said:
seems to work but i also get "The Microsoft Jet database engine could not
find the object". Make sure the object exists and that you spell its name
and
the path name correctly"

the form does stay open but that appears between any of the msgbox i call
if
there is no data

That's not a function of setting cancel = true, I suspect some other issue,
you'll need to do some digging I think.

Keith.
 
Back
Top