Stop Form from Opening

B

Bob Vance

My message box is operating perfect but can I also stop the Form [frmModify]
from opening as well.............Thanks Bob
Private Sub Form_Load()
DoCmd.Maximize

On Error Resume Next

' ------ this needs a criteria clause
Me.tbCompanyName = DLookup("CompanyName", "tblCompanyInfo")
'-------

' check for horse name
If Nz(Me.cbHorseName, 0) = 0 Then

MsgBox "(Client Invoice) Must be Edited from Main Menu/ClientInvoices!",
vbOKOnly + vbCritical, "Client Invoice "

End If


End Sub
 
D

Dirk Goldgar

Bob Vance said:
My message box is operating perfect but can I also stop the Form
[frmModify] from opening as well.............Thanks Bob
Private Sub Form_Load()
DoCmd.Maximize

On Error Resume Next

' ------ this needs a criteria clause
Me.tbCompanyName = DLookup("CompanyName", "tblCompanyInfo")
'-------

' check for horse name
If Nz(Me.cbHorseName, 0) = 0 Then

MsgBox "(Client Invoice) Must be Edited from Main Menu/ClientInvoices!",
vbOKOnly + vbCritical, "Client Invoice "

End If


End Sub


Assuming that you had to wait for the Load event so that you could check the
value of the (presumably) bound control cbHorseName, your best bet is to
simply close the form:

DoCmd.Close acForm, Me.Name, acSaveNo
 
B

Bob Vance

Thanks Dirk, That did the trick......................Bob :) :)

Dirk Goldgar said:
Bob Vance said:
My message box is operating perfect but can I also stop the Form
[frmModify] from opening as well.............Thanks Bob
Private Sub Form_Load()
DoCmd.Maximize

On Error Resume Next

' ------ this needs a criteria clause
Me.tbCompanyName = DLookup("CompanyName", "tblCompanyInfo")
'-------

' check for horse name
If Nz(Me.cbHorseName, 0) = 0 Then

MsgBox "(Client Invoice) Must be Edited from Main Menu/ClientInvoices!",
vbOKOnly + vbCritical, "Client Invoice "

End If


End Sub


Assuming that you had to wait for the Load event so that you could check
the value of the (presumably) bound control cbHorseName, your best bet is
to simply close the form:

DoCmd.Close acForm, Me.Name, acSaveNo


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top