Results 1 to 7 of 7
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    position to last record on a form from general module

    The segment of code shown below is within a general module. I need a correct method to move to the last record on the referenced form. (I could do that with a another sort, but would like to know how to do it with a single statement if possible.)



    Code:
    If Screen.ActiveControl.Name = "tbGAPuse" Then     'Error 2474 if we're not on a control
        
        dteGAPuse = Nz(DLookup("GAPuse", "QLibrary", "WorksID = " & lngID))
        If dteGAPuse = 0 Then Exit Function
    
    
        Forms("frmLibrary").Form.Filter = "GAPuse = " & "#" & dteGAPuse & "# AND CatNo > 9000"
        Forms("frmLibrary").Form.FilterOn = True
        Forms("frmLibrary").Form.OrderBy = "AliasVolID ASC, VolPos ASC"
        Forms("frmLibrary").Form.OrderByOn = True
        
        Forms("frmLibrary").Form.LblFltrOff.Visible = True
        
        strFldrGAP1 = DLookup("CtlgNo", "QLibrary", "[WorksID] = " & lngID)
        
        Forms("frmLibrary").Form.DoCmd.GoToRecord , , acLast     '<<<<<<<<< This doesn't work
      
        MsgBox strFldrGAP1 & " " & Forms("frmLibrary").Form.RecordsetClone.RecordCount  'DEBUG ONLY
        MsgBox Forms("frmLibrary").Form.TitleExp                                        'DEBUG ONLY
        Exit Function                                                                   'DEBUG ONLY
    End If

  2. #2
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    I don't think you can DoCmd against a form like that. Try something like

    Code:
        DoCmd.GoToRecord acForm, "frmLibrary", acLast
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    BINGO!

    Thanks Minty.

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    As this code is only for form frmLibrary, why not put it in the form module instead of a standard module?
    You can then use the Me. notation throughout e.g. Me.FilterOn=True
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    For right-click popup menus, Access can't find the Public Function unless it's in a General Module. I could create a general module transfer vector to get to the form's module, but since I have other functionality within the current module that needs to be in a general module, I chose not to do that.

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Never heard of a module transfer vector. I do know that custom command bars always had to call a function as you say. Fore me, the sole purpose of those functions was to call some other procedure. That could be form module procedures if they were scoped as Public instead of the default of Private.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Sorry Micron, I sometimes forget that not everyone that programs these days has main-frame system backgrounds. Essentially, it's a fixed location in storage that tells all the system modules where to find the major system components, sort of akin to what you described as:
    the sole purpose of those functions was to call some other procedure

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

Similar Threads

  1. Replies: 10
    Last Post: 03-06-2020, 07:14 AM
  2. Force a Requery from general module
    By GraeagleBill in forum Programming
    Replies: 10
    Last Post: 07-10-2018, 09:01 AM
  3. How to cause a form event to fire from a general module
    By GraeagleBill in forum Programming
    Replies: 10
    Last Post: 09-04-2016, 08:08 AM
  4. General Module - Implementing LiFo Stack
    By GraeagleBill in forum Programming
    Replies: 2
    Last Post: 05-13-2014, 01:15 PM
  5. Get position of record in continuous form
    By Whizbang in forum Forms
    Replies: 3
    Last Post: 11-02-2011, 01:47 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