Close Form In This Code

Hi,

Closing the current form will not work with this event. Period!

There is two ways of doing this.
1. Use Macros - bind it to the lost focus property field.
2. Use the form's timer event and interval.

Tried it.. whew what the heck.. Here is the code I am working with

Private Sub SFVINFen_GotFocus()

If Me.SFVINFen.ListCount = 0 Then
If MsgBox("VIN Does Not Exist! Would You Like To Continue With The New Order?", vbQuestion + vbYesNo, "VIN NOT FOUND!") = vbNo Then
Exit Sub
Else
Dim stDocName As String
DoCmd.OpenForm "Order Details", acNormal
DoCmd.GoToRecord , , acNewRec
Forms![Order Details].VIN.Value = Me.VinToFindFen
Forms![Order Details].ROFirst.Value = Me.FirstNameToFindFen
Forms![Order Details].ROLast.Value = Me.LastNameToFindFen

End If
Docmd.Minimize 'minimized for effect
Me.TimerInterval = 1000 ' set the timer
DoEvents '

End If

End Sub

Private Sub Form_Timer()
'close the form here
DoCmd.Close acForm, "frmNewOrdeVINVerify"
End Sub


Keep in mind this control is on the form that i want to close...
SFVINFen
Fen How

Note: Personally, I do not like this method myself. But it work.
 
Last edited:
Thanks however the DoCmd.Minimize minimizes the form I am going to "Order Details"

Do you have a better suggestion? I am at a loss here..

Fen
 
Hi Fen,

That's is very confusing.

The event "SFVINFen_GotFocus()" code is in the form "frmNewOrdeVINVerify"?

You wanted to close this form right?

The code I gave is to Minimized this current form "frmNewOrdeVINVerify" then use the current form's (frmNewOrdeVINVerify) Timer Interval and the form's Timer Event to close this Minimized form (frmNewOrdeVINVerify).

So, have you tried using the code?

Thanks however the DoCmd.Minimize minimizes the form I am going to "Order Details"
Do you have a better suggestion? I am at a loss here..
Fen
 
Maybe the confusion is the code with the nested IFThenELse?

Code:
If Me.SFVINFen.ListCount = 0 Then
     If MsgBox("VIN Does Not Exist! Would You Like To Continue With The New Order?", vbQuestion + vbYesNo, "VIN NOT FOUND!") = vbNo Then
     Exit Sub
     Else
     Dim stDocName As String
     DoCmd.OpenForm "Order Details", acNormal
     DoCmd.GoToRecord , , acNewRec
     Forms![Order Details].VIN.Value = Me.VinToFindFen
     Forms![Order Details].ROFirst.Value = Me.FirstNameToFindFen
     Forms![Order Details].ROLast.Value = Me.LastNameToFindFen
     End If
Docmd.Minimize 'minimized for effect
Me.TimerInterval = 1000 ' set the timer
DoEvents '
End If

End Sub

Private Sub Form_Timer()
'close the form here
DoCmd.Close acForm, "frmNewOrdeVINVerify"
End Sub

Here is the logic of your code.

Code:
If true then show message box
   if vbNo then Exit subroutine
   else
   open "order Detail" and do autofill but do not close current form yet
   end if
'it was true so, I need to close the current form here.
let me minimized the form then
set the form timer interval to one second
finish the event with DoEvents
end the event.

When timer interval activates the form's Timer event
Close this current form
end

Thanks however the DoCmd.Minimize minimizes the form I am going to "Order Details"
Do you have a better suggestion? I am at a loss here..
Fen
 

Users who are viewing this thread

Back
Top Bottom