Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Schenectady, New York, USA
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Accessing a sub forms fields from the Main Form (Access 2000)

    Perhaps I'm making this more complicated tan it needs to be but here is what I'm trying to do.

    I have a sub form that is dynamic in that it is created each time a user enters new data. This sub form contains the current available justification messages that can be applied to the information on the main form. When the user clicks the save button I want to access the radials buttons taht are in individual frames.
    Here are some of the details on the form:
    1. The Frames are named Frame1 through however many justifications are present. I want to use a loop like this
    for i = 1 to me.frm_just_Add_sfrm!No_Justifications
    If me.frm_just_Add_sfrm("Frame" & i)

    2. There is a field called No_Justifications hidden on the sub form that contains the count of how many justifiactions are present.

    3. Each Frame contains the Justification message key in the TAG field so if the Frame value is set to 1 (selected) I want to add that justification to my Veto Justification table.

    I'm stuck on trying to access the fields using 'me.frm_just_Add_sfrm' . Any Help would be greatly appreciated. Forms! frm_just_Add_sfrm!NoJustifications is found either.. <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23>


    I've attached an image of my screen.

    Thank you
    Attached Images Attached Images
    Don
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18> <img src=/S/flags/NewYork.gif border=0 alt=NewYork width=30 height=18> "Life on Earth is expensive, but at least it includes a free trip around the Sun."

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Accessing a sub forms fields from the Main Form (Access 2000)

    I'm uncertain of what you mean by the subform being "created each time a user enters new data". Are the individual "frames" the pairs of Justification Msg and No Msg items? Are these actually option groups each containing 2 radio buttons? From your question, it sounds like this subform is unbound, so I don't quite understand what you mean about it being created each time a user enters new data. You also have neglected to give us a clue as to what your Veto Justification table looks like and whether the buttons are on the parent form or the subform. If you are trying to check each of the option groups and use the value found to insert the tag for that option group into a field in Veto Justificationtton when the users clicks a button on the parent form, you can either call a public routine on the subform, or you have to change your code to properly address the subform instead of trying to use the syntax you're using. For one thing, you can only address the full collection of controls on the subform, and since buttons and labels are also controls, you won't be able to use the "For i = 1 to ..." syntax unless you know exactly how many frames are on the form. If you do, you can use something like this, assuming that "frm_just_Add_sfrm" is the name of the subform and that the values of each pair of radio buttons are 0 and 1:

    Dim strTag as String
    dim grpFrame as OptionGroup

    For i = 1 to Me.frm_just_Add_sfrm.Form!No_Justifications
    Set grpFrame = Me.frm_just_Add_sfrm.Form("Frame" & i)
    If grpFrame > 0 Then
    strTag = grpFrame.Tag
    >> code to insert string into table goes here.
    Charlotte

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Accessing a sub forms fields from the Main Form (Access 2000)

    I don't know what the structure of your Veto Justifications table is, but I would use one record for each justification. That way, the subform could be a continuous subform, and you wouldn't need all this code.

    To refer to controls on a subform, you must use the name of the subform as a control on the main form. This is not necessarily the same as the name it has in the database window. To see the name of the subform as a control, open the main form in design view, and click once on the subform. Don't click a second time, because then you select something in the subform. If you do that by accident, click on the main form outside the subform, then click once on the subform. You will see the control name in the Object dropdown in the Formatting (Form/Report) toolbar, and in the Properties window.

    You should be able to use something like this:

    For i = 1 To Me.<ControlName>.Form.No_Justifications
    If Me.<ControlName>.Form.Controls("Frame" & i)

    where <ControlName> is the name of the subform as a control on the main form.

  4. #4
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Schenectady, New York, USA
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Accessing a sub forms fields from the Main Form (Access 2000)

    Thank you Charlotte.
    Here is what is happening and some background.

    I have a database where I interrogate a text file that is the enacted Bill for NYS budget for a particular Fund. There are other items in the Bill that are entered manually through this form. They are being entered so if the Governor decides to Veto an Item It can be flagged with the correct justification. The Justification messages can change at a moments notice or just slightly for a few items. I keep the Justification message is a separate table. I have an Item table that is populated from the main form (the one I sent.) The sub form contains an entry for each possible Veto Justification Message for the Budget Year they are working with. Each Justification has it's own frame with the values of 1 for a justification message and 3 for no justification. The Frame defaults to 3 on its creation. Here is how the form gets created.

    There is a form that the user receives to select the Bill they want to work in. After they make there selection they click a button which executes code in a module that deletes the old sub form 'frm_just_Add_sfrm' and then builds a new form from scratch. (Different years will have different numbers of messages.) the sub form and form are not bound. Each Item that is flagged for Veto can have more than one message associated to to it. (I have a table that contains the Item PK's, and Justification Message Key. I want to look at the sub form when the user saves the record and if the Frame is set to 1 then I will get the Justification Id from the Frames Tag and create a record using the key information from my Form.

    Sorry this is so long winded. I really appreciate your help with this. (I'm answering this from home so an answer can wait until Monday.)

    Thank you
    Have a nice weekend.
    Don
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18> <img src=/S/flags/NewYork.gif border=0 alt=NewYork width=30 height=18> "Life on Earth is expensive, but at least it includes a free trip around the Sun."

  5. #5
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Schenectady, New York, USA
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Accessing a sub forms fields from the Main Form (Access 2000)

    Thank you Hans,


    I was responding to Charlotte when you response came in.


    I needed the format that you gave. The problem here is that each item can have any combination of pre written justifications. I need a way for the user to select the Veto Justification that will pertain to the Item they are working on.

    The VJMs are constantly changing and modified by the State Lawyers up until the last minute of producing the Vetos. The Items are also entered in as they come from the front office. There are only 10 business days from the time of the legislative enactment for the Governor to have the Vetos presented back to the legislature. There are many last minute negotiations that go one and VJM adjustments. This form was a way for me to reproduce it when they open that Bill ( there are 5 Different Bills with thousands of entries) When an item is chosen I want this form to come up showing any current assigned messages and then when saved delete the old entries and just write the new selections to the table. When I use a bound form the dynamic entries are all hidden when there are no VJM's. Last year we produced (9000 Vetos). It produced a few ulcers.
    Don
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18> <img src=/S/flags/NewYork.gif border=0 alt=NewYork width=30 height=18> "Life on Earth is expensive, but at least it includes a free trip around the Sun."

  6. #6
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Schenectady, New York, USA
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Accessing a sub forms fields from the Main Form (Access 2000)

    Hi, Hans, hope you had a nice weekend.

    I tried the code you suggested and now I get "Object doesn't support this property or method." Could I be missing a reference? I'm enclosing images for my references, the properties for the subform and the relationships. If you have a better ideas/suggestions on how I should/could create the middle table table (As noted on the relationship image) please suggest it. I sometimes make things more complex than they really should be. Not all items will contain a justification. Some could and will have more than one.

    Hans,

    I just figured out what I needed to do. I am using this format and it is working.

    Me.frm_just_Add_sfrm("Frame" & i)

    Thanks for all your help.
    Attached Files Attached Files
    Don
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18> <img src=/S/flags/NewYork.gif border=0 alt=NewYork width=30 height=18> "Life on Earth is expensive, but at least it includes a free trip around the Sun."

Posting Permissions

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