Results 1 to 9 of 9
  1. #1
    Lounger
    Join Date
    Aug 2002
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need help using SQL, Tabs, and subforms (Access 97)

    If you have a form with a Tab Control on it and that Tab Control has two pages, each with its own subform, how can an SQL
    command grab the information off of one of the subforms?

    INSERT INTO Table
    VALUES ([Forms]![ParentForm].[FieldA]);

    doesn't work,

    INSERT INTO Table
    VALUES ([Forms]![ParentForm].[TabCtl1].[SubformA].[FieldA]);

    doesn't work,

    NSERT INTO Table
    VALUES ([Forms]![SubformA].[FieldA]);

    doesnt' work.

    How can I get the SQL statement to get the information from the field on the subform in the Tab Control in the parent form?

    Any help is greatly appreciated.

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Need help using SQL, Tabs, and subforms (Access 97)

    You reference a field in a subform via the subform control name (not the name of the form being used as a subform, although they may be the same). That it is on a tab control is irrelevant. Using your names, the correct syntax is (this assumes SubFormA is the name of the subform control):
    Forms!ParentForm!SubFormA.form.FieldA
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    Lounger
    Join Date
    Aug 2002
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need help using SQL, Tabs, and subforms (Access 97)

    INSERT INTO ModalityImages
    VALUES (1, 1, [Forms]![ImageAnalysisDisplay]![Child6].MRI.txtDate, [Forms]![ImageAnalysisDisplay]![Child6].MRI.txtTime, "test");

    doesn't work

    INSERT INTO ModalityImages
    VALUES (1, 1, [Forms]![ImageAnalysisDisplay]![TabCtl1].[Child6].[txtDate], [Forms]![ImageAnalysisDisplay]![TabCtl1].[Child6].[txtTime], "test");

    doesn't work.

    I have a form : ImageAnalysisDisplay
    a Tab Control on that form : TabCtl1
    a subform on one of the pages of that Tab Control : Child6
    the subform is based on a form called : MRI

    the SQL statement will not get the information from the text boxes, or combo boxes on the subform.

  4. #4
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Need help using SQL, Tabs, and subforms (Access 97)

    Have another look at what Mark has said of how to address a subform control.
    Your statement
    <<INSERT INTO ModalityImages
    VALUES (1, 1, [Forms]![ImageAnalysisDisplay]![TabCtl1].[Child6].[txtDate], [Forms]![ImageAnalysisDisplay]![TabCtl1].[Child6].[txtTime], "test");
    >>
    should probably read like
    INSERT INTO ModalityImages
    VALUES (1, 1, [Forms]![ImageAnalysisDisplay]![Child6].form![txtDate], [Forms]![ImageAnalysisDisplay]![Child6].form![txtTime], "test");

    However, I don't think you have the INSERT statement quite right, Access defines a single INSERT as

    INSERT INTO target [(field1[, field2[, ...]])]
    VALUES (value1[, value2[, ...])

    HTH
    Pat

  5. #5
    Lounger
    Join Date
    Aug 2002
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need help using SQL, Tabs, and subforms (Access 97)

    the field1, field2 thing isn't necessary if the values you are inserting are in the right order.
    Probably safer to specifically say the order, but that's a different issue.

    Just out of curiosity, what's HTH mean?

    Brad

  6. #6
    Lounger
    Join Date
    Aug 2002
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need help using SQL, Tabs, and subforms (Access 97)

    OK, you were both right. Yes, I needed to read the first post more carefully. And, yes, I needed to make the changes suggested in the second post. I would never have come up with that on my own. I'm just a lowly engineering undergrad, what do I know about programming? Thanks bunches, you rock.

  7. #7
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Need help using SQL, Tabs, and subforms (Access 97)

    HTH means "Hope This Helps".
    It's not so much what you may or may not know about programming, but generally the syntax is crucial in statements.
    Pat <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

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

    Re: Need help using SQL, Tabs, and subforms (Access 97)

    Why are you referencing the tab control at all? The subforms appear on the tab control pages, but they're actually bound to the parent form. You don't need any kind of reference to the tab control when referencing the subform.
    Charlotte

  9. #9
    Lounger
    Join Date
    Aug 2002
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need help using SQL, Tabs, and subforms (Access 97)

    Yes, I know that now. <img src=/S/blush.gif border=0 alt=blush width=15 height=15>

Posting Permissions

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