Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2002
    Posts
    154

    Question Unanswered: Module level syntax

    Does anyone know the syntax for or if you can refer to a module level variable of a parent form from a subform and do work on that variable, possibly even change its value? I thank you in advance for your time and your responses.

  2. #2
    Join Date
    Dec 2004
    Location
    Coon Rapids, Minnesota
    Posts
    41
    I believe it is Me.Parent.Form

  3. #3
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Are you talking about a global type variable where you Dim MyVariableName as String (or integer or variant or date, etc..) after the Option Compare Database line in your main/parent form?

    Then you should be able to refer to and manipulate that variable from within the subform or other places.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  4. #4
    Join Date
    Nov 2002
    Posts
    154

    Question Yes that is it

    Yes, pk, a global variable declared after the option explicit statement and before any subroutines it is. When I tried to refer to it it on the subform it would cause a runtime error and say that the variable didn't exist. Even declaring the variable as public didn't help. Thanks.

  5. #5
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    feetdontfailme, I'm a little confused by your last post if that solved the issue or not. If I don't see another post from you, I'll assume that the issue is resolved. Otherwise, post another thread that you're still having a problem.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  6. #6
    Join Date
    Nov 2002
    Posts
    154

    Unhappy No, not resolved

    What I have is a little long type variable that I have declared after the OPTION EXPLICIT statement like: PRIVATE LNGNUMBER AS LONG.
    I can't refer to it on the subform in order to manipulate it (add to it) because although the intellisense will capitalize it right, when I do the action that triggers that manipulation it tells me that the long variable does not exist (on the subform). I should have said this but the first thing I did before originally posting was to try to use it on the subform, but it would not work. I thank you in advance for your time and your responses.

  7. #7
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Variable example

    feetdontfailme,

    I did this EXTREMELY fast, but does this example help any? There are other ways of doing this. This is a couple ways: one way utilizing a local variable and a text box, another with a function in a module, and another way I refer to the Public variable in the MainForm via Forms!MainForm.XVariable (which is what I think you're looking for - ie..Forms!MainForm.XVariable = Forms!MainForm.XVariable * 3 or some other calculation.) or in your case...Forms!MainForm.LNGNumber = Forms!MainForm.LNGNumber * something.
    Attached Files Attached Files
    Last edited by pkstormy; 08-03-07 at 18:51.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

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