Results 1 to 3 of 3
  1. #1
    bsc is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2011
    Posts
    28

    Variable substitution problem.


    I am trying to use variable substitution in the following line and cant get it.

    'What I have working:
    Forms!frmMain.frmSalesSubForm.Visible = True

    X will actually come from the value in a ADODB recordset named "rst", but this should sufice for my example.

    'What I want:
    dim X
    X = rst!SubFormName
    Forms!frmMain.X.Visible = True


    The error on the ....visible = true statement is

    Compile Error:
    Method or Data Member not found.

    Any help appreciated.
    bryan

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    What you need to do is address the subform container control that holds the form. So if the control and its form have same name, try:

    Forms!frmMain.Controls(x).Visible = True
    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
    bsc is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2011
    Posts
    28
    Thanks for the primer.

    Explicitly using "Forms!frmMain.Controls(x).Visible = True" did not work.


    But the syntax below works fine. The primary difference in what I was tryign to do is the use of an exclamation mark instead of a period between the frmMain and the subform substituted variable.

    V
    Forms!frmMain!(rst!SubFormName).Visible = True


    Using 'Me' in the syntax, however, did somethign interesting. I had written

    Me!(recordset!Name).Visible = True


    and the editor automatically corrected it to say

    Me(rst!SubFormName).Visible = True


    Either one works fine.

    Thanks...problem solved.

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

Similar Threads

  1. Replies: 0
    Last Post: 08-10-2011, 11:59 AM
  2. Object variable or With block variable not set
    By walter189 in forum Programming
    Replies: 1
    Last Post: 07-28-2011, 08:51 AM
  3. Problem with filtering on DATE Variable
    By SIGMA248 in forum Programming
    Replies: 1
    Last Post: 04-01-2011, 10:33 AM
  4. Replies: 4
    Last Post: 08-05-2010, 01:26 PM
  5. Refering to variable form names inside a variable
    By redpetfran in forum Programming
    Replies: 2
    Last Post: 05-21-2010, 01:39 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