Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2002
    Posts
    77

    Unanswered: parameters using form controls

    I am trying to create a query that references a form control. This is the SQL code

    SELECT dbo_DM_SiteToGroup.*
    FROM dbo_DM_SiteToGroup
    WHERE (((dbo_DM_SiteToGroup.strCorpName)=[Forms]![frmgrp]![Combo0]));

    The form is created already but when I run the query, message box pops up prompting me for
    Forms!frmgrp!Combo0

    I thoght I was goign to get the actual form and I make a selection from the combo box that gets passed
    to the query.


    I am working on access 2000 intalled on xp. Thanks for any hints.

  2. #2
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    If you get the prompt for Forms!frmgrp!Combo0, there are 3 things which would cause this prompt to appear...1. The form "frmgrp" is not open or 2. There is no field on the form which has the name Combo0 or 3. The select statement/query syntax is wrong.

    This..
    SELECT dbo_DM_SiteToGroup.*
    FROM dbo_DM_SiteToGroup
    WHERE (((dbo_DM_SiteToGroup.strCorpName)=[Forms]![frmgrp]![Combo0]));

    Should be...

    SELECT dbo_DM_SiteToGroup.*
    FROM dbo_DM_SiteToGroup
    WHERE (((dbo_DM_SiteToGroup.strCorpName)= ' " & [Forms]![frmgrp]![Combo0] & " '))"
    (to match on a string value)
    or
    SELECT dbo_DM_SiteToGroup.*
    FROM dbo_DM_SiteToGroup
    WHERE (((dbo_DM_SiteToGroup.strCorpName)= " & [Forms]![frmgrp]![Combo0] & "))"
    (to match on an integer value)
    Last edited by pkstormy; 09-29-07 at 01:01.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

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