Querying a Field in a Form

  • Thread starter Thread starter fridayxiii
  • Start date Start date
F

fridayxiii

I've built a simple form w/two fields: A and B. Boht fields are combo
boxes that retrieve their values from distinct tables. My goal is to
have field B display a list of values based on the value selected in
field A. So far I've been unable to accomplish this via hand-coded
SQL, or using the query builder. Can anyone point me to a resource or
offer advice on how to accomplish this?

Thx,
Brian
 
I've built a simple form w/two fields: A and B. Boht fields are combo
boxes that retrieve their values from distinct tables. My goal is to
have field B display a list of values based on the value selected in
field A. So far I've been unable to accomplish this via hand-coded
SQL, or using the query builder. Can anyone point me to a resource or
offer advice on how to accomplish this?

Thx,
Brian

Put code in the afterupdate event of A to assign a value to B. You
didn't mention what your criteria was, but it would look something
like this:
select case A
case 1
B="One"
case 2
B="two"
case other
B="unknown"
end select
 
Say the name of the forst combobox is CbxA, the name of the second combobox
is CbxB and they both are on a form named MyForm. CbxB must have a rowsource
that is a query that includes field A. Put the following code in the
AfterUpdate event of CbxA:
Me!CbxB = Null
Me!CbxB.Requery
Put the following expression in the criteria of Field A in CbxB's query:
Forms!MyForm!CbxA

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 
Say the name of the forst combobox is CbxA, the name of the second combobox
is CbxB and they both are on a form named MyForm. CbxB must have a rowsource
that is a query that includes field A. Put the following code in the
AfterUpdate event of CbxA:
Me!CbxB = Null
Me!CbxB.Requery
Put the following expression in the criteria of Field A in CbxB's query:
Forms!MyForm!CbxA

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
Thanks for the responses. The table behind CbxB will have occasional
additions, so I think this may be the best solution. I could use the
select case route but as B will be changing I think this is the best
route. Thanks again.
 
Back
Top