Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / March 2007

Tip: Looking for answers? Try searching our database.

Using form values in query statement

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
wildwatermelon12@yahoo.com - 05 Mar 2007 22:39 GMT
Hello~

  I am building a form where a user should choose a category from a
dropdown menu populated from the "categories" table, and then a second
dropdown menu should appear if there are any subcategories available
for the selected category. I have joined the tables in Access so that
there is a 1-to-many relationship between the categories.id field and
the subcategories.categoryID field. This is the query that Access
generated, and I then added the WHERE statement to include the form
value that the user generates:

    <cfquery name="getSubcategories" datasource="corpGov">
        SELECT
              categories.id
        AS
              categories_id, subcategories.id
        AS
              subcategories_id, subcategories.categoryID
        FROM
                categories
        INNER JOIN
                subcategories
        ON
                categories.id = subcategories.categoryID
        WHERE
                form.category.id = subcategories.categoryID
    </cfquery>

This is the form code that I am using right now:

<cfselect name="category" message="Please choose a category!"
required="yes">
                                    <cfloop query="getCategories">
                                        <cfoutput>
                                            <option value="#getCategories.id#">#getCategories.name#</
option>
                                        </cfoutput>
                                    </cfloop>
                                </cfselect>
                              </div></td>
                       </tr>

                    <!--- If Category defined above has Subcategories available,
display them in a dropdown menu --->
                        <cfif isDefined("form.category")>
                        <tr>
                          <td>
                             <div align="right">Subcategory :</div>
                            </td>
                          <td>
                             <div align="left">
                                <cfselect name="subcategories"
message="Please choose a subcategory!" required="yes">
                                            <option>None</option>
                                    <cfloop query="getSubcategories">
                                        <cfoutput>
                                            <option value="#getSubcategories#">#getSubcategories#</
option>
                                        </cfoutput>
                                    </cfloop>
                                </cfselect>
                              </div></td>
                       </tr>
                        </cfif>

I am getting the following error:

Error Executing Database Query.
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC
Microsoft Access Driver] Too few parameters. Expected 1.

If anyone has any suggestions, they would be very welcome! Thanks.

KC
wildwatermelon12@yahoo.com - 06 Mar 2007 16:04 GMT
On Mar 5, 3:39 pm, wildwatermelo...@yahoo.com wrote:
> Hello~
>
[quoted text clipped - 70 lines]
>
> KC

OK, I figured out that I need to switch the order of my WHERE
statement so that it reads like this:

WHERE
                subcategories.categoryID = form.category.id

But I am still getting the same "1 parameter" error. Any ideas?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.