Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / March 2005

Tip: Looking for answers? Try searching our database.

Closing a form only if value is selected.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
James - 09 Mar 2005 05:17 GMT
I have tried this under BeforeUpdate() and the following and I can't get it
to cancel the event.  I am trying to make the form give an error message if
no name is selected from the list.  Right now, if the EmlpoyeeID field is
left blank the form closes and updates the record.  What am I doing wrong?
----------start code---------------
Private Sub btnOkay_Click()
On Error GoTo Err_btnOkay_Click
       
   If IsNull(Me!EmployeeID) Then
       MsgBox "You must select an employee from the list"
       Me!lblEmployee.ForeColor = 255
       Me!EmployeeID.SetFocus
       Exit Sub
    Else
       Me!lblEmployee.ForeColor = 0
       DoCmd.Close
   End If

           
Exit_btnOkay_Click:
   Exit Sub

Err_btnOkay_Click:
   MsgBox Err.Description
   Resume Exit_btnOkay_Click
   
End Sub
-------------end code----------------
Geoffs - 09 Mar 2005 10:19 GMT
Hi,
Is your EmployeeID a String Value? To make sure that you catch all types of
emptyness change the test to :-
If IsNull(Me.EmployeeID) Or Me.EmployeeID = "" Then

> I have tried this under BeforeUpdate() and the following and I can't get it
> to cancel the event.  I am trying to make the form give an error message if
[quoted text clipped - 24 lines]
> End Sub
> -------------end code----------------
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.