Results 1 to 9 of 9
  1. #1
    Join Date
    Apr 2004
    Posts
    17

    Unanswered: refering to a subform from a report

    OK, I have an Access report, and on the "on open" event it runs an sql statment that gets 2 dates (input boxes) from a subform in the main form and compares them to a field in a table and spits out the result. the tricky part is that the main form doesnt actually contain the subform, it brings it up on the bottom part of it (so technically they are 2 forms). the questions is how would I refer to the texts boxes that get the dates in the report?
    I tried:

    " & Forms![main_form]![submain_form].form![control_name] & "

    I get the following error : Database can't find the form 'main_form' referred to in a marco expression or VB code.

    PLEASE HELP, i have been knocking my head over this for 2 days now.

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    forms!motherformname!daughterformname.control

    ?

    izy
    currently using SS 2008R2

  3. #3
    Join Date
    Apr 2004
    Posts
    17
    Originally posted by izyrider
    forms!motherformname!daughterformname.control

    ?

    izy
    still giving me the same error message.

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    are the names are really what you think they are?
    check properties¦other¦name on the mother & daughter & control

    izy
    currently using SS 2008R2

  5. #5
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    and
    the main form doesnt actually contain the subform
    is a little confusing: either its a subform (meaning you can see it's location in design view and it is contained by the mother - wherever it is on the mother doesn't matter), or its an independent form.

    "doesn't actually" leaves room for doubt

    izy
    currently using SS 2008R2

  6. #6
    Join Date
    Apr 2004
    Posts
    17
    the names are actually right. The thing is the main form is like a menu with different buttons and it calles like 30 other forms. No you cant see it in desgin view. If i pull the daughterform up independantly and type the control name it works fine, but if i go thru the "master" form it doenst even regcognize it.
    I'm thinking of setting a global vaiable for the input boxes? would you think that would work? and if it does, how would i go about it?
    (BTW thanks for the help so far, this is my first time here)

  7. #7
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    LATER
    - actually, my reply is is bull$#it.
    you need to have the called form as an object not as a text string - unfortunately i gotta go right now so i cant fix it for you: i'll check back tomorrow if nobody fixes it for you by then


    forms!mother!thisGuyMustBeOnTheMotherForm.controlName is not going to work for you.

    forms!anyOldForm!control
    will do the job, but i guess your problem is that you dont know the name of anyOldForm

    if you dont already have a convenient module (OLD-speak "Global Module"), make one, and add
    Global NameOfTheformIwantToPlayWith as string

    and go back to forms!mother

    wherever you have
    docmd.openform "whatever"

    replace with
    NameOfTheformIwantToPlayWith = "whatever"
    docmd.openform NameOfTheformIwantToPlayWith


    and now you can talk to
    NameOfTheformIwantToPlayWith
    from anywhere in the application

    izy
    Last edited by izyrider; 04-16-04 at 14:29.
    currently using SS 2008R2

  8. #8
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    one way:

    in a module:
    Global globjBox as textbox


    in the mother form
    docmd.openform "TheformName"
    set globjBox = forms!TheformName.TheTextBoxName




    in the report _Open() event
    msgbox globjBox ' i.e. the report knows the contents of TheTextBoxName on TheformName


    izy
    currently using SS 2008R2

  9. #9
    Join Date
    Apr 2004
    Posts
    17
    thanks Izy,

    i know it was a couple of days late, but i got it.

    code:

    'in module
    Public gnStartTxt as String


    in report

    gnStartTxt = Forms!myform.controlname

    SQL Statment ....... "WHERE #& gnStartTxt &# ......."

    Thx

Posting Permissions

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