Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form displays unwanted record sets

Status
Not open for further replies.

Telestar

Instructor
Jul 12, 2004
7
CA
We have a form in our Discipline database that is used to update (attendance and what they did) our "Saturday School" (You're bad .. you go to school on Saturday)

We have a combo that is populated by a query that gives unique dates of all Saturdays where updates are required.

The form is based on a query of all Saturday school incidents that have not been updated. Value in attendance field is 0.

In our case the combo has two dates, once a date is picked then the appropriate code runs:

'Get the date and find the record
Private Sub fPickDate_AfterUpdate()

Dim matchset As Object

Set matchset = Me.Recordset.Clone
matchset.FindFirst "[StartDate] = #" & Format(Me![fPickDate], "mm\/dd\/yyyy") & "#"
If Not matchset.EOF Then Me.Bookmark = matchset.Bookmark
End Sub


Well that's fine ... it does find the location of the records, but we still see the records that do not match the date.

We did try setting the query's criteria on the date from the form itself. That gives me nothing at all. (I suspected that)

Do I know enough to be dangerous?

Thnks
Telestar
 
How are ya Telestar . . . . .

Its doing exactly what you have it setup to do!

Remember a [blue]RecordsetClone[/blue] is just a copy of the records returned by the forms [blue]RecordSource[/blue]. So when you FindFirst and set the bookmark, your[blue]just bringing that record into view[/blue] amoungst all the records in the set.

To see only the records for that date, you need to [blue]modify the query to include criteria for the selected date[/blue]. You can do this with [blue]SQL[/blue] in [blue]VBA[/blue], appending the criteria to the SQL and updating the [blue]RecordSource[/blue]. In this way, you wouldn't need the RecordSet. Also, you'd need some means of reverting back to [purple]View All Saturdays[/purple], another change in SQL.

So its a common SQL to [purple]View All Saturdays[/purple] and the same SQL appended with Date Criteria to [purple]view the combobox selection[/purple].

If ya have any problems with the SQL in VBA, post back with the SQL and we'll get ya straight . . . . .




Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top