Re: Close form?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Ken Snell [MVP] (kthsneisllis9_at_ncoomcastt.renaetl)
Date: 03/21/05


Date: Sun, 20 Mar 2005 19:14:37 -0500

What is the exact error message and number that you're getting?

-- 
        Ken Snell
<MS ACCESS MVP>
"Tony Williams" <tw@tcpinvalid.com> wrote in message 
news:uieLcQTLFHA.2252@TK2MSFTNGP15.phx.gbl...
> Thanks Ken tried that but form still wont close still get the error 
> message?
> Tony
> "Ken Snell [MVP]" <kthsneisllis9@ncoomcastt.renaetl> wrote in message
> news:%23La3pHLLFHA.2136@TK2MSFTNGP14.phx.gbl...
>> Why are you using the LostFocus event? That event will not let you reset
> the
>> focus as you wish. If your intent is to capture that the user is trying 
>> to
>> leave the control without having entered a value, then use the Exit 
>> event,
>> as it can be cancelled and thus keep the focus on the same textbox.
>>
>> Private Sub txtMontha_Exit(Cancel As Integer)
>> On Error GoTo Err_txtMontha_LostFocus
>> Dim MsgStr As String
>> Dim TitleStr As String
>> MsgStr = "You can not enter a record without  " _
>>    & "completing the Qtr End Date" & vbCrLf & vbCrLf _
>>    & "Do You Wish To Go Back " _
>>    & "And Enter The Qtr End Date?"
>> TitleStr = "Qtr End Date Must Be Entered"
>> If IsNull(Me!txtMontha) Or Me!txtMontha = "" Then
>>     If MsgBox(MsgStr, vbYesNo, TitleStr) = vbYes Then
>>         Cancel = True
>>     Else
>>       Me.Undo
>>         DoCmd.Close acForm, Me.Name
>> End If
>> End If
>> Exit_txtMontha_LostFocus:
>>     Exit Sub
>>
>> Err_txtMontha_LostFocus:
>>     MsgBox Err.Description
>>     Resume Exit_txtMontha_LostFocus
>> End Sub
>>
>> -- 
>>
>>         Ken Snell
>> <MS ACCESS MVP>
>>
>>
>>
>> "Tony Williams" <tw@tcpinvalid.com> wrote in message
>> news:uX9g9CLLFHA.1528@TK2MSFTNGP09.phx.gbl...
>> > If the user clicks No in this message I want the form to close, but I
> get
>> > a
>> > message that says This action can't be carried out while processing a
> form
>> > or report.
>> > Here is my code
>> > Private Sub txtMontha_LostFocus()
>> > On Error GoTo Err_txtMontha_LostFocus
>> > Dim MsgStr As String
>> > Dim TitleStr As String
>> > MsgStr = "You can not enter a record without  " _
>> >   & "completing the Qtr End Date" & vbCrLf & vbCrLf _
>> >   & "Do You Wish To Go Back " _
>> >   & "And Enter The Qtr End Date?"
>> > TitleStr = "Qtr End Date Must Be Entered"
>> > If IsNull(Me!txtMontha) Or Me!txtMontha = "" Then
>> >    If MsgBox(MsgStr, vbYesNo, TitleStr) = vbYes Then
>> >        Cancel = True
>> >        Me.txtMonthlabela.SetFocus
>> >        Me.txtMontha.SetFocus
>> >
>> >    Else
>> >      Me.Undo
>> >        DoCmd.Close acForm, Me.Name
>> > End If
>> > End If
>> > Exit_txtMontha_LostFocus:
>> >    Exit Sub
>> >
>> > Err_txtMontha_LostFocus:
>> >    MsgBox Err.Description
>> >    Resume Exit_txtMontha_LostFocus
>> > End Sub
>> >
>> > Can anyone help?
>> > Thanks
>> > Tony
>> >
>> >
>> >
>>
>>
>
> 


Relevant Pages

  • Re: Close form?
    ... Private Sub txtMontha_Exit ... Dim TitleStr As String ... TitleStr = "Qtr End Date Must Be Entered" ... > Dim MsgStr As String ...
    (microsoft.public.access.formscoding)
  • Close form
    ... Private Sub txtMontha_LostFocus ... Dim MsgStr As String ... Dim TitleStr As String ... TitleStr = "Qtr End Date Must Be Entered" ...
    (microsoft.public.access.queries)
  • Close form?
    ... Private Sub txtMontha_LostFocus ... Dim MsgStr As String ... Dim TitleStr As String ... TitleStr = "Qtr End Date Must Be Entered" ...
    (microsoft.public.access.formscoding)
  • Re: Close form?
    ... "Tony Williams" wrote in message ... > Dim TitleStr As String ... > Exit Sub ...
    (microsoft.public.access.formscoding)
  • Project Error
    ... Private Declare Sub Sleep Lib "Kernel32" ... Dim strDataSrc As String ...
    (microsoft.public.vb.bugs)