Results 1 to 7 of 7
  1. #1
    sonntagc is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    13

    Setting FOCUS correctly when using TAB control.

    hello. i have a tabcontrol called TABCTLMAIN. it has 3 tabs at the moment. tab(0) labeled FIND CLAIM; tab(1) labeled MANUALLY FINALIZE CLAIM, and tab(2) labeled PROCESS LOG. form opens and starts at first field on tab(0), which is fine. i display data and have user input on this tab. i have a boolean function called MANUAL UPDATE ALLOWED. when user clicks on second tab i call the function. depending on contents of some fields, if the result of function is true, then i want to let user go to tab(1) and set focus to field CBOCLMSTATUS (a combo box). if the result of function is false, i want to prevent user from leaving ... i.e., stay on tab(0), but set focus to field REQUESTOVERRIDE (a text field). i am trying to use the ONCLICK event of tab(1).



    so, if user tries to go to 2nd tab, the boolean function checks various conditions, and figures out if claim can be finalized. if true, go to 2nd tab for additional data input, otherwise stay on main tab, and request help.

    Code:
    Private Sub Manually_Finalize_Claim_Click()
        
        If ManualUpdateAllowed Then
            Me.TabCtlMain.Value = 1
            Me.cboClmStatus.SetFocus
        Else
            Me.TabCtlMain.Value = 0
            Me.txtRequestOverride.SetFocus
        End If
    End Sub
    i stripped down the boolean function while trying to debug. basically, the code below is checking to make sure a desired field is not "blank". will eventually add additional tests, but this is as simple as i can get at the moment. when the form opens, the REFF8 field doesn't have any data in it. when i try to go to 2nd tab, it goes there fine, which is not what want/expect.
    Code:
    Private Function ManualUpdateAllowed() As Boolean
        If IsEmpty(Me.txtFindREFF8) Or IsNull(Me.txtFindREFF8) Then
            MsgBox "REF-F8 does not contain data"
            ManualUpdateAllowed = False
        Else
            MsgBox "REF-F8 is oK"
            ManualUpdateAllowed = True
        End If
    End Function
    Last edited by June7; 09-17-2014 at 12:00 PM.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    Did you step debug? Does the Click event fire?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    sonntagc is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    13
    well, i think you're on to something there. debugging, when i click the "tab" portion of the tab-ctrl to go to the 2nd page, it doesn't appear the ONCLICK event is firing. should i be using the ONCLICK event of the whole tab control, and not the event for the page? i think i will try that next.

  4. #4
    sonntagc is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    13
    THANKS, i am now pointed in the right direction. testing the ONCLICK event for the whole tab container/control is where i need to be. i will work forward from here. thanks for the help.

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Actually, the OnClick event of the whole tab control will not pop when clicking on one of the 'tabs;' that will only execute if you click on the blank area, to the right of the tabs, where future tabs would go, if added, unless things have changed with v2010 (which is always possible.) Instead you need to use the Control's OnChange event.

    Also note that

    IsEmpty() is used to see whether or not a Variable has been initialized; it is not used against a Control, as you're doing, here.

    In checking a Control, to see if it is populated, you need to test for Nulls and Zero-Length Strings (ZLSs.) There are a number of ways to do this; most experienced developers have their favorite. To check for both at the same time I would use

    If Nz(Me.txtFindREFF8, "") = "" Then

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  6. #6
    sonntagc is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    13
    so now the problem is that the ONCLICK code fires everytime i click on any of the tabs. i only want to execute the code when i try to access the FINALIZE CLAIM MANUALLY tab(1). i don't want it to fire when i go to the PROCESS LOG(2) tab or the FIND CLAIM tab(0).

    plus, i probably need to add 2 or 3 more tabs to this form. i only want it to execute the code when user tries to access the FINALIZE CLAIM MANUALLY tab(1).

    any thoughts? THANKS in advance.

  7. #7
    sonntagc is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    13
    missinglinq: thanks for the claification. i will change code to check field contents per your suggestions. is the behavior i describe above because i'm using the ONCLICK instead of ONCHANGE for the tab control? when referring to a tab control, does the "change" part refer to changing tabs? i mostly use that property when i work on fields, and the "change" part, i thought, referred change in value of the field. that's why i didn't think about it for the tab control.

    does anyone know of a good book i can get that explains the specifics of properties/events for Access 2010. i know a lot of it is online, but maybe my ADD affects me. i find using the online MS help not as easy to figure out versus books, code samples, and forums. sorry ... better discussion for other forum.

    THANKS

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 8
    Last Post: 03-01-2014, 02:15 PM
  2. Opening a report and setting focus to it
    By Kirtap in forum Programming
    Replies: 2
    Last Post: 02-19-2014, 12:05 PM
  3. Setting the focus on a subform
    By Paul H in forum Forms
    Replies: 3
    Last Post: 01-10-2012, 09:17 AM
  4. Setting focus on a tabbed form
    By crowegreg in forum Forms
    Replies: 21
    Last Post: 08-27-2011, 09:22 AM
  5. Setting Focus on a Form
    By MFeightner in forum Forms
    Replies: 1
    Last Post: 07-30-2009, 07:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums