sql syntax for subform combo

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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

here's the latest rendition
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
 
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 said:
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.
here's the latest rendition:
For the "got focus" event procedure..

cbodescription.rowsource = "select
product.productid,product.description,product.cost from product where
product.subcategoryname=me.parent.cbosubcategory"
 
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 said:
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.
here's the latest rendition:
For the "got focus" event procedure..

cbodescription.rowsource = "select
product.productid,product.description,product.cost from product where
product.subcategoryname=me.parent.cbosubcategory"
 
Thanks All for your help! I have much to learn about Access / Sql fundamentals

To

----- Larry Linson wrote: ----

You need to use the value of the subcategoryname, not the reference as yo
have it, and since there is only one table involved, you can omit the tabl
references... if subcategoryname is a text field, tr

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

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

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

Larry Linso
Microsoft Access MV


toms said:
subform(orderdetails subform) combo box (cbodescription). I want it to ge
it's criteria from a combo(cbosubcategory) on the mainform(orders1). I kee
getting errors saying basically that Access can't interpret the statement
For the "got focus" event procedure.
product.productid,product.description,product.cost from product wher
product.subcategoryname=me.parent.cbosubcategory
 
Back
Top