Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2002
    Location
    Belgium
    Posts
    243

    Unanswered: same subforms twice in a form

    Hi everyone

    I created a subfrm ("subfrm1") wit a couple of textboxes on it.
    I added this subform on a form ("mainfrm").
    Afterwards I copied and pasted it on the same subform. This second instance I called "subfrm2".

    What I want to achieve is that when clicking on a textbox, I can retrieve following information :
    - the name of the clicked textbox
    - the name of the subform where that textbox belongs to
    - the name of the mainform where that subform belongs to

    Till now, when clicking on a textbox (no matter on which subform, I always get "subfrm1".

    Any idea how to get this info?

    Thanks

  2. #2
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    - the name of the clicked textbox
    Screen.ActiveControl.Name

    - the name of the subform where that textbox belongs to
    Me.Name

    - the name of the mainform where that subform belongs to
    Me.Parent.Name
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  3. #3
    Join Date
    Nov 2002
    Location
    Belgium
    Posts
    243
    Hi StarTrekker,

    Thanks for your reply. I will check it this evening.
    I still have an issue with the two subforms giving the same name, even I had changed it in the properties window.

    Is it possible to put two times the same subfrm on a form?
    If yes, should I drag and drop them from the database window twice or can I import it once and then copy it (which I did I think)?

    Thanks

  4. #4
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Hang on a sec... you are putting the exact same subform on a mainform twice? Why?

    Yes you can do it, but of course it's going to report the same name since it's the same object.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  5. #5
    Join Date
    Nov 2002
    Location
    Belgium
    Posts
    243
    OK, I wanted to spare you the details, but if you insist ....
    We want a planningtool.
    Meaning :
    - we have 13 machines.
    - each machine should run daily (7 days a week)
    - every day we have 3 shifts
    - each machine has 5 operators (with different skills)

    We want an overview of a week with 7 days and 3 shifts each day for all machines. Using the planningtool the shiftleader can assign people to a certain function on a certain machine for the selected day.

    I give you an example : when the shiftleader has an empty weekoverview, he should click on a textbox. Depending on the checkbox I can retrieve its name which tells me the weekday and the shiftnumber. So I know now which team is working on that moment of the day / week.
    This textbox belongs to a subform called "FunctionX" and that subform belongs to a form "MachineX" (where the X stand for the function- or machinenumber). Now I (want to) know for which machine and which function I need an operator.
    I query the DB and select an operator who might operate the specified machine in the specified function and who is working at the specified day and the specified shift.

    No matter what textbox you click, always the same code should be executed. The only thing that makes a difference are the parameters which I retrieve from the names of the objects (textbox, subform and form).

    Because there are 7 days in a week and 3 shifts every day, I need 21 objects.
    But this for each machine : so 13 * 21 = 273.
    But this for 5 functions on each machine : so 273 * 5 = 1365
    I need 1365 objects I need to have it all covered.

    First of all this is way behind the limits of access.
    Secondly I don't like typing 1365 times the same code.

    Therefore I was thinking of creating a subform for just one function (just containing 7 * 3 = 21 objects) and write code for each textbox.
    I then put this subform 5 times (for each function on a machine) in a parentform. Finally I put that parentform 13 times on my mainform (for each machine).
    And I was hoping to have my issue solved.

    An alternative is to create a subform and copy it as much as I need in the database explorer, but then I have a lot of subforms; which I want to avoid if I could solve this in an other way.

    Hope you get the picture and maybe a brilliant idea.

    Thanks

  6. #6
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Secondly I don't like typing 1365 times the same code.
    I wouldn't like to type ANYTHING into that many objects

    I'm not sure exactly what you're looking at there, but surely there has to be an easier way. I can't imagine needing to creating so many objects.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

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