Combo values based on query

  • Thread starter Thread starter Rose B
  • Start date Start date
R

Rose B

I have a combo field where the underlying query has a criteria on a date field
of "[Forms]![frmGroupTrips].[GroupTripDate]". If I use the combo on
the form, the list is not there. If I go into the query via properties and
run
it, it returns the single record I need. When I go back to the form then the
record is there in the combo list - but if I go to another record, with
another date then it is still there and shouldn't be. Why does the query
behind the combo box not update based upon the current data? (Or more
precisely -
how can I get it to do that?)

The SQL of the query is

SELECT Event.EventID, Event.EventTitle, Event.EventDate
FROM Event
WHERE (((Event.EventDate)=[Forms]![frmGroupTrips].[GroupTripDate]));
 
Rose,
Try using the OnCurrent event of the form to Requery the Combo box.
Private Sub Form_Current()
cboYourComboName.Requery
End Sub
Also, I'm not sure if this would cause a problem or not, but try using a
bang (!) in your criteria...
= [Forms]![frmGroupTrips]![GroupTripDate]
it, it returns the single record I need.
If, for each record, the combobox returns only one value, you might
consider using a caculated field, or a DLookup. Combos are used to select a
value from multiple values.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."

Rose B said:
I have a combo field where the underlying query has a criteria on a date
field
of "[Forms]![frmGroupTrips].[GroupTripDate]". If I use the combo on
the form, the list is not there. If I go into the query via properties and
run
it, it returns the single record I need. When I go back to the form then
the
record is there in the combo list - but if I go to another record, with
another date then it is still there and shouldn't be. Why does the query
behind the combo box not update based upon the current data? (Or more
precisely -
how can I get it to do that?)

The SQL of the query is

SELECT Event.EventID, Event.EventTitle, Event.EventDate
FROM Event
WHERE (((Event.EventDate)=[Forms]![frmGroupTrips].[GroupTripDate]));
 
The Requery did the trick! Thanks (The query won't always return a single
netry - it's just that I had a small amount of test data. Have just added
some more test data and now works fine with multiple returns too)

Al Campagna said:
Rose,
Try using the OnCurrent event of the form to Requery the Combo box.
Private Sub Form_Current()
cboYourComboName.Requery
End Sub
Also, I'm not sure if this would cause a problem or not, but try using a
bang (!) in your criteria...
= [Forms]![frmGroupTrips]![GroupTripDate]
it, it returns the single record I need.
If, for each record, the combobox returns only one value, you might
consider using a caculated field, or a DLookup. Combos are used to select a
value from multiple values.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."

Rose B said:
I have a combo field where the underlying query has a criteria on a date
field
of "[Forms]![frmGroupTrips].[GroupTripDate]". If I use the combo on
the form, the list is not there. If I go into the query via properties and
run
it, it returns the single record I need. When I go back to the form then
the
record is there in the combo list - but if I go to another record, with
another date then it is still there and shouldn't be. Why does the query
behind the combo box not update based upon the current data? (Or more
precisely -
how can I get it to do that?)

The SQL of the query is

SELECT Event.EventID, Event.EventTitle, Event.EventDate
FROM Event
WHERE (((Event.EventDate)=[Forms]![frmGroupTrips].[GroupTripDate]));
 
Back
Top