View Full Version : Simple I think


fenhow
01-18-2008, 05:30 PM
Hi,

I have this code that pops up a Yes or No option. The yes option works fine but when I select No it closes my database?

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

End If


End Sub

Can someone please help?

Thanks.

Fen How

T.Smith
01-18-2008, 05:53 PM
It would be easier to read if you had tabs in the statements. Do you have any errors on compile?

Toby

jdraw
01-19-2008, 06:35 AM
Hi,

I have this code that pops up a Yes or No option. The yes option works fine but when I select No it closes my database?

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

End If


End Sub

Can someone please help?

Thanks.

Fen How

When you select No, it closes this Sub. What were you expecting it to do?

T.Smith
01-19-2008, 06:44 AM
I see that it closes the Sub but that wouldn't close the database as fenhow stated above.

T.Smith
01-19-2008, 06:53 AM
First thing fenhow should do is remove the "Dim stDocName As String" as its no longer needed. :)