Results 1 to 4 of 4
  1. #1
    lawdy is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    175

    Trouble with the word 'me'

    I use the 'Me' word in a lot of code as



    Me(pubStrCurrentCell).Caption = pubStrJobName ' pubStrCurrentCell is the name of an object on a form

    It works real well in code on that form. However, if I want to use that same line in a module, it does not work at all. Is there anyway to reference an object in a modlue using a variable?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,601
    Yes there is.

    strForm = "My Form Name"
    strControl = "My Control Name"

    Forms(strForm).Controls(strControl).Caption
    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
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    Another way to do this would be to pass the form reference to the code module as an argument:

    sub MySub(frm as form)
    frm(pubStrCurrentCell).Caption = pubStrJobName ' pubStrCurrentCell is the name of an object on a form
    end sub

    then use

    MySub(me)

    to call it.

    You might have to have pubStrJobName as a second argument to MySub

    John

  4. #4
    lawdy is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    175
    Thanks to both of you for solving my problem.

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

Similar Threads

  1. Replies: 8
    Last Post: 04-14-2013, 01:33 PM
  2. Call word object and import word fields
    By silverspr in forum Programming
    Replies: 3
    Last Post: 12-10-2012, 11:32 PM
  3. Access to Word - Multiple Word Templates?
    By alpinegroove in forum Programming
    Replies: 11
    Last Post: 06-12-2012, 04:42 PM
  4. Trouble printing labels (data from Access) in Word
    By Austruck in forum Import/Export Data
    Replies: 2
    Last Post: 08-08-2011, 10:23 AM
  5. Trouble with (R)
    By NOTLguy in forum Access
    Replies: 3
    Last Post: 10-29-2010, 11:55 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