sql syntax for combo event procedure

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

To
 
T

Tom

You need to refer to the cbosubcategory in full in the
query.

i.e. not me.parent.cbosubcategory

but:

Form!ParentFormName!SubFormName.Form!cbosubcategory





-----Original Message-----
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"
 
G

Guest

Thanks Tom

How different is it when you specify a control in VBA using SQL as compared to using the control properties? How would the statements look

Thanks for your time.
 
G

Graham Mandeno

Hi Tom

The "Me.Parent.cboSubcategory", should not be part of your RowSource SQL
string, but instead you need to substitute the *value* from that control.
Like this:

cbodescription.rowsource = "select
product.productid,product.description," _
& "product.cost from product where product.subcategoryname=" _
& chr(34) & me.parent.cbosubcategory & chr(34)

Note: Chr(34) is a double-quote character. I am assuming that your field
[subcategoryname] is text, so you need to enclose the matching string in
quotes. If it is a numeric field, then remove the two instances of Chr(34).
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


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"
 
G

Guest

Cool! Thanks Graham & Tom for your help

----- Graham Mandeno wrote: ----

Hi To

The "Me.Parent.cboSubcategory", should not be part of your RowSource SQ
string, but instead you need to substitute the *value* from that control
Like this

cbodescription.rowsource = "selec
product.productid,product.description,"
& "product.cost from product where product.subcategoryname="
& chr(34) & me.parent.cbosubcategory & chr(34

Note: Chr(34) is a double-quote character. I am assuming that your fiel
[subcategoryname] is text, so you need to enclose the matching string i
quotes. If it is a numeric field, then remove the two instances of Chr(34)
--
Good Luck

Graham Mandeno [Access MVP
Auckland, New Zealan


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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top