Using SQL Query in Access

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sreenadh
    New Member
    • Nov 2006
    • 2

    Using SQL Query in Access

    I have a feeling that this is a silly question. But pls excuse me as i am a newbie and i have been beating abt this issue for 2 days and i have not been to solve it.

    I made a form with 1 combo box, 1 buttom and a Grid DTC.

    Now, for example. Taking the scenario of a car showroom.
    By choosing the name of a brand or Company(like Honda) in the combo box and clicking on the button. I want to display every model(like Civic, Accord) that is available from that brand.

    I wrote the query to do it in Queries part of access. It is working fine. But i am unable to write that query in the VB window that pops up when i go to the Events in the property of button.

    Pls guide me
    Thanks
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32668

    #2
    Please post in here what you have in the properties of the form for :
    Record Source
    Filter
    Order by
    Allow Filters

    Also, if the record source is the name of a query, then post the SQL of that query (Design view of query then select SQL View from the View menu).

    Comment

    • Tanis
      New Member
      • Mar 2006
      • 143

      #3
      If it's working as a named query, why change it to SQL? DoCmd.OpenQuery "myquery" will work just as well.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32668

        #4
        I wasn't suggesting that anyone change the query to SQL.
        Merely to change the view of an existing query to show the embedded SQL in order to post it in here.

        Comment

        • MMcCarthy
          Recognized Expert MVP
          • Aug 2006
          • 14387

          #5
          Originally posted by sreenadh
          I have a feeling that this is a silly question. But pls excuse me as i am a newbie and i have been beating abt this issue for 2 days and i have not been to solve it.

          I made a form with 1 combo box, 1 buttom and a Grid DTC.

          Now, for example. Taking the scenario of a car showroom.
          By choosing the name of a brand or Company(like Honda) in the combo box and clicking on the button. I want to display every model(like Civic, Accord) that is available from that brand.

          I wrote the query to do it in Queries part of access. It is working fine. But i am unable to write that query in the VB window that pops up when i go to the Events in the property of button.

          Pls guide me
          Thanks
          Further to what NeoPa said:

          Can you supply the following ...

          1. The name of the form. I assume the record source of the form is the aforementioned query. If you open the query in design view and then change the view to sql you can copy and paste the full sql statement here.
          2. The system name of the combobox control and the row source of the combo box. This might just be a value list like "Honda";"Nissan ";..etc.
          Or it might be based on a sql query or a table.
          3. The system name of the command button.
          4. 'a Grid DTC' - are you talking about a datagrid or a subform in datasheet view?

          With this information we can give you the VBA code to use in the button click event. Essentially the options are to set a filter or change the record source of the form dynamically. We will have a better idea which option to use if you can provide the above information.

          Mary

          Comment

          • sreenadh
            New Member
            • Nov 2006
            • 2

            #6
            First off, i am extremly sorry for thr delay in replying.
            Grid DTC is a datagrid. I dragged it from the tool bar menu. i named the button "btnList"
            The query in perfectly working. When i run it in the query section. BUt in the form, i dont know how to implement it.
            If i select honda and click the button. I want the list of all the honda cars in the data grid

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32668

              #7
              Sreenadh,

              Can you revisit my earlier post and find the information for us please.
              Then we can start to look at this seriously. At the moment we're all a little in the dark.

              Comment

              Working...