2 questions - format a date to year & filter based on combo box

  • Thread starter Thread starter Maggie
  • Start date Start date
M

Maggie

2 Questions.

1 - How do I make a date field in a form so that it only
accepts the year. right now I have to type in 1/1/1997 to
capture 1997.

2 - There are two fields that create a primary key in my
table. They are Event & Location. On my form, I have a
combo box where you select the event. In the next combo
box I want it to filter on event and only show the
locations of that particular event.

Or, if possible, select both the Event & Location from one
combo box and have both location and event values stored
in their respective fields.

Any suggestions?

Thanks,

Maggie
 
2 Questions.

1 - How do I make a date field in a form so that it only
accepts the year. right now I have to type in 1/1/1997 to
capture 1997.

A Date/Time field is stored internally as a double float count of days
since midnight, December 30, 1899. As such, any date is a precise
instant of time. 1997 was NOT a precise instant of time - it was a
whole bunch of instants <g>.

If you just want to store a year, I'd suggest using an Integer field
rather than any sort of date.
2 - There are two fields that create a primary key in my
table. They are Event & Location. On my form, I have a
combo box where you select the event. In the next combo
box I want it to filter on event and only show the
locations of that particular event.

See http://www.mvps.org/access/forms/frm0028.htm for some sample code.
Or, if possible, select both the Event & Location from one
combo box and have both location and event values stored
in their respective fields.


You could have a combo box showing both fields; the event (or
whichever is the more specific one) would be the bound column of the
combo. In the combo's AfterUpdate event you can populate the other
field:

Private Sub cboEventLocation_AfterUpdate()
Me!txtLocation = Me!cboEventLocation.Column(1)
End Sub

where the Column property is zero based - this will store the *second*
field in the combo's rowsource.
 
Back
Top