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 / Modules / DAO / VBA / February 2008

Tip: Looking for answers? Try searching our database.

SetFocus

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DCPan - 26 Feb 2008 23:46 GMT
Hi all,

I set a condition on a textbox so that on "when exit", it will see if
another textbox value is zero, and if the value is not zero, see if the
textbox is null, otherwise, set the cursor back to the textbox.

The if then statements do work as the msgbox is triggered to notify the user
that comments need to be entered when the value isn't zero.

But the setfocus isn't working and it isn't a typo...what's up?

Private Sub DailyComments_Exit(Cancel As Integer)
   
   'Set up Error Handling Tracer
   strModule = "Form_frm_DailyVariance"
   strProcedure = "DailyComments_Exit"

   'Error Handling
   On Error GoTo ErrorFlow

   'Check to see if a comment is needed
   If Me.DailyVariance <> 0 Then
       
       'Check to see if there are any comments
       If IsNull(Me.DailyComments) Then
           
           MsgBox "You must explain why the daily variance is not zero in
the
               comment section!", _
               vbInformation, "Clarification needed!"
   
           'Set focus on the comment box
           Me.DailyComments.SetFocus
           
       End If
   
   End If
   
Exit_Code:

   Exit Sub

ErrorFlow:

   'Use Global_Error_Handler
   HandleError Err.Number, Err.Description, strModule, strProcedure, True

   'Exit Error Handler
   Resume Exit_Code

End Sub
fredg - 26 Feb 2008 23:59 GMT
> Hi all,
>
[quoted text clipped - 47 lines]
>
> End Sub

Incorrect event.
Use the control's BeforeUpdate event, not it's Exit event.

Then, instead of:
          'Set focus on the comment box
            Me.DailyComments.SetFocus
           
Write:
    ' Return to the Comment Box without updating
    Cancel = True
   

Signature

Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

DCPan - 27 Feb 2008 00:16 GMT
Hi Fred,

You rock.

The event was actually correct, but the cancel = true did the trick.  I
needed the exit event because I didn't want the user to click away without
entering something.

Thanks again!

> > Hi all,
> >
[quoted text clipped - 59 lines]
>     Cancel = True
>    
 
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.