Results 1 to 4 of 4
  1. #1
    omahadivision is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    21

    Programming VBA to run every time a different record on a form is accessed

    Hello all,



    I have a bound checkbox that determines whether or not a tab on my tab control is visible using the following code:

    Code:
    If FTIR1Checkbox = True Then
    Me.TabCtl689.Pages(0).Visible = True
    Else
    Me.TabCtl689.Pages(0).Visible = False
    End If
    My question is, how can I make my database run this code every time a different record is accessed? Currently, I've programmed it into a click event, so it only changes when the box is actually clicked. I tried OnLoad to no avail. I have some records where the box is checked and others where it's not, and I'd like the tab to automatically be visible or invisible based on whether the box for that particular record is checked.

    Thanks!

    -Dave

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    49,621
    Put it in the form Current event.
    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
    omahadivision is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    21
    Easier than I thought. Thanks!

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    2,955
    At some point, when using the Form_Current Property, you may need to differentiate between a New Record that is being 'visited' and an Existing Record.

    Code for a New Record, only:
    Code:
    Private Sub Form_Current()
     If Me.NewRecord Then
      'Code for New Record goes here
     End If
    End Sub

    Code for an Existing Record, only:
    Code:
    Private Sub Form_Current()
     If Not Me.NewRecord Then
      'Code for Existing Record goes here
     End If
    End Sub

    And, if you have one task to be done on a New Record but another task to be done on an Existing Record:
    Code:
    Private Sub Form_Current()
     If Me.NewRecord Then
      'Code for New Record goes here
     Else
      'Code for Existing Record goes here 
     End If
    End Sub


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

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Replies: 2
    Last Post: 08-28-2012, 02:11 AM
  2. Replies: 2
    Last Post: 11-14-2011, 03:17 PM
  3. Db form programming?
    By swat in forum Programming
    Replies: 19
    Last Post: 09-02-2011, 02:22 PM
  4. Replies: 4
    Last Post: 07-22-2011, 12:52 PM
  5. FORM Fields Programming
    By accessprogram in forum Programming
    Replies: 23
    Last Post: 12-28-2010, 01:26 PM

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 - Senior Forums