Results 1 to 3 of 3
  1. #1
    Stephenson is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Location
    North West
    Posts
    110

    Replacement for Me. in public sub


    I'm trying to write public subs to control several forms and am having a bit of trouble with this public sub I believe because of the Me. statement.

    This is what I have in my module.

    Code:
    Public Sub Current()
        On Error Resume Next
        If frmcurrent.CurrentRecord = 1 Then
            Me.Current.cmdBack.Enabled = False
            Me.cmdFirst.Enabled = False
        Else
            Me.cmdBack.Enabled = True
            Me.cmdFirst.Enabled = True
        End If
        If Me.CurrentRecord = Me.Recordset.RecordCount Then
            Me.cmdLast.Enabled = False
        Else
            Me.cmdLast.Enabled = True
        End If
        If Me.CurrentRecord >= Me.Recordset.RecordCount Then
            Me.cmdNext.Enabled = False
        Else
            Me.cmdNext.Enabled = True
        End If
        If Me.NewRecord Then
           Me.cmdNew.Enabled = False
        Else
            Me.cmdNew.Enabled = True
        End If
    Dim rst As DAO.Recordset
    Dim lngCount As Long
    Set rst = Me.RecordsetClone
    With rst
    .MoveLast
    lngCount = .RecordCount
    End With
    Me.tboCount = Me.CurrentRecord & " of " & lngCount
    
    
    End Sub


    This is what I'm using in my Form.

    Code:
    Private Sub Form_Current()
        Call Current
    End Sub

    Is there a replacement for Me. or do I need to write this a different way?

    Thanks for having a look.

  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,815
    You want to call this public procedure that is in a general module from several forms?

    Me alias only works behind form and report objects. Will have to do something different.

    Options might be:

    1. Screen.ActiveForm

    2. pass name of form to function

    3. pass form as an object

    NOTE: ending CODE tag needs a /, like [/CODE].
    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
    Stephenson is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Location
    North West
    Posts
    110
    Thanks June7. I'll give those a try.

    I have several forms that I'm trying to keep looking the same and am using this module to keep the redundant programming to a minimum. I'm new to this so if there is a better way I'm all ears.

    Thank you for the help.

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

Similar Threads

  1. Any replacement for the old SetValue
    By toniartist in forum Access
    Replies: 1
    Last Post: 03-17-2012, 08:58 PM
  2. Addup and Replacement values query
    By desp in forum Access
    Replies: 1
    Last Post: 10-17-2011, 06:17 AM
  3. Sendkeys replacement
    By numberguy in forum Programming
    Replies: 6
    Last Post: 07-14-2011, 08:29 AM
  4. Sendkeys replacement
    By numberguy in forum Forms
    Replies: 3
    Last Post: 10-29-2010, 07:20 AM
  5. Replacement in table with VB code
    By miziri in forum Access
    Replies: 2
    Last Post: 06-28-2010, 01:38 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