Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    New Lounger
    Join Date
    Jul 2002
    Location
    London, Kent, England
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Subform controlled from a query (97)

    I have 20 buttons, that run various queries.

    how can i have a subform on the same page display the information from the the selected query

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subform controlled from a query (97)

    If your queries contains the same fields, you could change the recordsource of the subform.
    If they are all different, then you'll have to create different subforms and change the source object of the subform control.
    Both can be done in the on click event of the buttons.
    If you need help with the code, feel free to ask.
    Francois

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

    Re: Subform controlled from a query (97)

    Given what you described, I'm guessing that these 20 queries you run are Action queries (Appends, Updates, deletes)? If so, then there really isn't any way to show what has been done after the fact.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    New Lounger
    Join Date
    Jul 2002
    Location
    London, Kent, England
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subform controlled from a query (97)

    No, the 20 queries all reference the same set of tables, what i don't know how to do, is point the subform to the answer each query produces.
    The queries are just standard queries.

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

    Re: Subform controlled from a query (97)

    Use code like

    Sub cmdFirstQuery_Click()
    sbfSubForm.RecordSource = "qryQuery1"
    End Sub

    Here, cmdFirstQuery is a command button, sbfSubForm is the name of the subform control (not necessarily the same as the name of the subform in the database window) and qryQuery1 the name of the query that is to be displayed in the subform.

  6. #6
    New Lounger
    Join Date
    Jul 2002
    Location
    London, Kent, England
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subform controlled from a query (97)

    Thanks for the replies all..

    Hans, will give that a try, a see where i get. [img]/forums/images/smilies/smile.gif[/img]

    many thanks

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

    Re: Subform controlled from a query (97)

    Keep in mind that while Access is marketed as an end-user product, that isn't the way you're trying to use it. You're edging into developer territory the minute you do anything except use the wizards, and *nobody* makes it easy for developers. <img src=/S/crazy.gif border=0 alt=crazy width=15 height=15> From a developer point of view, though, Access is really quite friendly. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    Charlotte

  8. #8
    New Lounger
    Join Date
    Jul 2002
    Location
    London, Kent, England
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subform controlled from a query (97)

    HansV, i *think* i get thte idea of your code, but i'm getting an error message.

    I put that code into the buttons, and put a subform on the main form. (A tabbed one) When i click on a button, it comes up with

    'Compile Error:'
    'Method or Data Member not found'

    If i change the line to read:

    Forms!xxSubreport.RecordSource = "Query1"

    I get : - Run time error 2450, 'Microsoft access can't find the form 'xxSubForm' referred to in a macro expression or Visual Basic Code'

    The only thing i can think is because the subform is on a tab. im trying to find out how i have to refer to a tab, with little joy, ive tryed ME!xxSubreport, and MainTab!xxSubreport.RecordSource = "Query1" . but with little joy [img]/forums/images/smilies/sad.gif[/img]

    Steve

  9. #9
    New Lounger
    Join Date
    Jul 2002
    Location
    London, Kent, England
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subform controlled from a query (97)

    err forgot to mention, it highlights the '.RecordSource =' bit in the code area.

    I also tried the thing on a normal form, but it made no difference, same errors.

  10. #10
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Subform controlled from a query (97)

    HansV is vacationing for a while, so I'll see if I can guide you through this. I think your problem lies with the manner in which you are trying to refer to the subform record source. You need to specify the main form first, then the subform control on the main form, and then the recordsource. So it should look something like:

    Forms![MyMainForm]![subfrmControl].Form.RecordSource="Query1"

    A good way to do these sort of things is to use the expression builder in Access. It will construct the string correctly so you can use it in code or as criteria in a query. Hope this solves the problem - post back if you still have trouble.
    Wendell

  11. #11
    New Lounger
    Join Date
    Jul 2002
    Location
    London, Kent, England
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subform controlled from a query (97)

    Thanks for the help Wendell, its still brings up an error message 438..
    Im trying to attach the db, but im using Opera, and it doesn't like lots of Java n stuff /sigh

    (Its supposed to support it, but it never works for me [img]/forums/images/smilies/sad.gif[/img]

  12. #12
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Subform controlled from a query (97)

    Does your subform contain a drop-down combo box? If so there is a known situation that causes the 438 error, which is related to the combo box not having the data source be the same time of field as the RowSource for the combo. MS Knowledge Base article Q236469 gives further details on the issue and how to solve it, although they embed lots of gibberish in it. (Sorry I don't have any experience with Opera, so I can't help much there - you might try the forum on browsers and see if anyone can suggest a solution.)
    Wendell

  13. #13
    3 Star Lounger
    Join Date
    Sep 2002
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subform controlled from a query (97)

    Forgot my pw . so had to make a new account so that i could attach a sample file.

    It still gives an error, this time its runtime 438

    Example file should be attached
    Attached Files Attached Files

  14. #14
    3 Star Lounger
    Join Date
    Sep 2002
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subform controlled from a query (97)

    No Wend, the example is a straight 3 buttons on a forms, with a subform. 3 available queries.

    What i hope to do with this at some point, is have a means to go to a hyperlink, so all of the records in the subform will have another field with a hyperlink in it
    Then, click a button to go to that word or excel file.

    The database that i am actually working on has this setup at the moment, and all the hyperlinks are already there. Im just not sure how its done at the moment. but hope to figure it out soon.. :}

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

    Re: Subform controlled from a query (97)

    For a start, you have not defined a subform only an empty shell. You will have to define a subform (xxSubform) with all the fields from table Memoid. After defining this you can then plug the recordsource of this subform then requery this subform.

    On further investigation I find that the Main form is also based upon table Memoid, what are you trying to do?
    HTH
    Pat

Page 1 of 2 12 LastLast

Posting Permissions

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