sql syntax for subform combo

message from =?Utf-8?B?dG9tcw==?= on 23 May 2004
Hi,

I'm having some rookie difficulty trying to write an event procedure for a subform(orderdetails subform) combo box (cbodescription). I want it to get it's criteria from a combo(cbosubcategory) on the mainform(orders1). I keep getting errors saying basically that Access can't interpret the statement.

For the "got focus" event procedure..

cbodescription.rowsource = "select product.productid,product.description,product.cost from product where product.subcategoryname=me.parent.cbosubcategory"

The error is probably obvious to you, but it escapes me...

thanks in advance.

Tom
 
Larry Linson replied to =?Utf-8?B?dG9tcw==?= on 23 May 2004
You need to use the value of the subcategoryname, not the reference as you
have it, and since there is only one table involved, you can omit the table
references... if subcategoryname is a text field, try

cbodescription.rowsource = "select productid, description, cost from
product where subcategoryname=""" & me.parent.cbosubcategory &"""""

if, for some reason the subcategoryname field is defined as numeric, use

cbodescription.rowsource = "select productid, description, cost from
product where subcategoryname=" & me.parent.cbosubcategory

Larry Linson
Microsoft Access MVP

"toms" <anonymous@discussions.microsoft.com> wrote in message
news:810ED266-279A-4B1C-B6A8-C213571141ED@microsoft.com...
subform(orderdetails subform) combo box (cbodescription). I want it to get
it's criteria from a combo(cbosubcategory) on the mainform(orders1). I keep
getting errors saying basically that Access can't interpret the statement.
product.productid,product.description,product.cost from product where
product.subcategoryname=me.parent.cbosubcategory"
 
=?Utf-8?B?dG9tcw==?= replied to Larry Linson on 23 May 2004
Thanks All for your help! I have much to learn about Access / Sql fundamentals!

Tom
 
tina replied to =?Utf-8?B?dG9tcw==?= on 23 May 2004
AFAIK, you can't use the Me.Parent reference outside of VBA. try the
following

cboDescription.RowSource = "SELECT Product.ProductID, Product.Description,
Product.Cost FROM Product WHERE Product.Subcategoryname = " &
[Forms]![Orders1]![cboSubcategory]

hth

"toms" <anonymous@discussions.microsoft.com> wrote in message
news:810ED266-279A-4B1C-B6A8-C213571141ED@microsoft.com...
subform(orderdetails subform) combo box (cbodescription). I want it to get
it's criteria from a combo(cbosubcategory) on the mainform(orders1). I keep
getting errors saying basically that Access can't interpret the statement.
product.productid,product.description,product.cost from product where
product.subcategoryname=me.parent.cbosubcategory"
 

Archived message: sql syntax for subform combo (MS Access Error Message)