limit combo box based on valud on form?

  • Thread starter Thread starter Kim
  • Start date Start date
K

Kim

Hi,

how do I limit a query that fills a combo box based on a value on a form?

what property do I need to address on the Combo?>


right now I have this in the rowsource

SELECT viewSingeClassDates.classDATESID, viewSingeClassDates.classDATES FROM
viewSingeClassDates WHERE viewSingeClassDates.classdatesID=classDatesID;

there is a classdatesID value ont he form


what am I doing wrong?

I get the the full results of the query as opposed to the limited results
based on the classdatesID

Help
Thanks in Advance
Kim
 
Hi Dennis,
thanks for the reply.
that is what I thought I was doing.
my query is viewSingeClassDates
and the value on the form is classDatesID

I am at a loss why this is not working.
in the rowsource I have

SELECT viewSingeClassDates.classDATESID, viewSingeClassDates.classDATES FROM
viewSingeClassDates WHERE viewSingeClassDates.classdatesID=classDatesID;

what am I missing?
 
Base the contents of the combo box on a query and put the criteria in your
query based on your form.
 
Just tested it & you need to remove the WHERE section in your Rowsource
property because the criteria is in the Query. Also, I had to out a
combo.requery in the after update event of the field ClassDatesID on your
form so that the combo would refresh its contents.
 
Hi LGC
trying to compare
viewSingeClassDates.classdatesID to the field on the form (classDatesID)
 
Kim,

The where clause in your query is ineffective. Your saying- include all
records where classdatesID = classdatesID, which will return all of them as
all values will equal themselves. What are you actually trying to compare
viewSingeClassDates.classdatesID to?

LGC
 
ok I was incorrect about which field its productID instead of classdatesID..

and here if the code that is provinding what I need.

Private Sub cmbClassDatesForChange_BeforeUpdate(Cancel As Integer)
Me.cmbClassDatesForChange.RowSource = "SELECT
viewSingeClassDates.classDATESID, viewSingeClassDates.classDATES FROM
viewSingeClassDates where productID=" & Me.ProductID
End Sub

thanks for your help
 
Back
Top