Results 1 to 4 of 4
  1. #1
    RLJ is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    9

    Form Variable

    I have this code for oppening a form below and I need the from name to be a variable as the use can open the form from various other forms within the database.


    Code:
    Private Sub Form_Load()
        Me.LoanNumberLookup = Forms![frmLoanDetail]![LoanID]
    End Sub
    I'm not sur how to make the form name a variable as the active form.

    Thanks for your help.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,524
    I'd probably use OpenArgs instead. At the point this code runs, the form being opened is probably the active form, so Screen.ActiveForm would probably refer to it rather than the form that opened it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    qa12dx is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Location
    india
    Posts
    112
    i'd give a generic name in from properties - format-caption
    then have a unbound textbox in form header to display form name

    on the trigger u use to open the form do;

    openform - xyz
    conditional setvalue for the textbox (if no need for condition; textbox-properties-control source- ="Account - " & [LoanID])

  4. #4
    RLJ is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    9
    I came up with this after some playing around and it seems to work fine.
    Code:
    Private Sub Form_Load()
        Dim FrmName As Form
        Set FrmName = Screen.ActiveForm
        Me.LoanNumberLookup = [FrmName]![LoanID]
    End Sub

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

Similar Threads

  1. Object variable or With block variable not defined
    By PorscheMan in forum Programming
    Replies: 3
    Last Post: 01-16-2013, 01:53 PM
  2. Replies: 0
    Last Post: 08-10-2011, 11:59 AM
  3. Replies: 4
    Last Post: 08-05-2010, 01:26 PM
  4. Refering to variable form names inside a variable
    By redpetfran in forum Programming
    Replies: 2
    Last Post: 05-21-2010, 01:39 PM
  5. Replies: 1
    Last Post: 04-13-2010, 12:18 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