Results 1 to 4 of 4
  1. #1
    Join Date
    May 2004
    Posts
    18

    Unanswered: The Variable problem

    there is a little problem I am having
    I am dealing with several forms and I want to build a function in the module to access all forms with the changes in the formname variable
    here is what I have

    This code is under a module
    DocumentSelector is a combo box in Form1
    Opendocument is a Button in Document1
    Const formname = "Form1"

    If Forms!formname!DocumentSelector = "Document1" Then
    Forms!formname!Opendocument.HyperlinkAddress = Path & "Document1.doc"

    This code does not work however, if i do

    If Forms![Form1]!DocumentSelector = "Document1" Then
    Forms![Form1]!Opendocument.HyperlinkAddress = Path & "Document1.doc"

    so the only problem is that when I replace the actual test of Form1 with a variable formname = "Form1" it will not work...


    If you have any idea, please let me know,...
    Thank you in advance

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    use: forms(formname)
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    May 2004
    Posts
    18

    Thank you Teddy

    Thanks a lot Teddy. But can you give me a reason why it doesn't work? Just so I can avoid it in the future


    Thanks

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Well, basically the variable you were passing is a string. The "forms!targetform!targetobject" method does not accept any parameters. The "forms(targetform)" method accepts a string, or string variable for the form name. Basically you were trying to pass a variable to something that doesn't accept any variables.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •