Counting records in filtered form from junction table

L

Leonard

Hi

I have a form based on a junction table.

I filter this form for an activity

DoCmd.applyFilter, "ActivityName = " & cmbactivity


All works well. Except, when there is no activity, the form still displays
the first record in the table and displays a 1 record count in the status
bar.

One possible solution I thought was to count the filtered records and if =1
then null all other controls.

So, how could I count the filtered records or is there something I'm really
missing here?

Thanks

Leonard
 
M

Michel Walsh

Hi,



cmbActivity cannot return Null, an error would have occurred. There is
probably a not null value returned by cmbActivity that makes the criteria
satisfied for one record, the one you see displayed.


You can try:

If 0=len(Me.cmbActivity & vbNullString) then
DoCmd.ApplyFilter, False
Else
DoCmd.applyFilter, "ActivityName = FORMS!FormNameHere!cmbActivity"
End If



Hoping it may help,
Vanderghast, Access MVP
 
L

Leonard

Thanks for that Michael, great idea that works!

I have another follow-on question but I'll post it as a new post.

Much appreciated

Leonard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top