RE: How do I filter a datasheet using VBA?

Tech-Archive recommends: Fix windows errors by optimizing your registry



Ofer,

Thank you ... this worked beautifully!

Cheers,
Dirk
Winnipeg, Canada


"Ofer" wrote:

> So did you write on the on open event of the form the code:
>
> Me.Filter = "(([qry Reports].PROJ_ID=6000))"
> Me.FilterOn = True
>
>
> "rupertsland" wrote:
>
> > Hi Ofer.
> >
> > It didnt' work. If anything, it bumped me into debug mode and crashed Access
> > (I'm using Access 2003).
> >
> > After regaining conciousness ... I tried manually filtering the project ID
> > of 6000. In the properties box for the form, the Filter property shows:
> >
> > (([qry Reports].PROJ_ID=6000))
> >
> > So I'm not sure whether to include the (()) or what to do. Any other
> > suggestions?
> >
> >
> > Dirk
> > Winnipeg, Canada
> >
> >
> > "Ofer" wrote:
> >
> > > Try this
> > >
> > > Me.Filter = "[TableName].[FieldInTableName]='6000'"
> > > Me.FilterOn = True
> > >
> > >
> > >
> > > "rupertsland" wrote:
> > >
> > > > Greetings.
> > > >
> > > > I'm trying to write a VBA procedure to apply a filter to a form when it is
> > > > opened by a user. I only want to filter on one field. In this case, PROJ_ID =
> > > > 6000. Sounds simple. The coding I tried to use, unsuccessfully, was:
> > > >
> > > >
> > > > Private Sub Form_Open(Cancel As Integer)
> > > >
> > > > Me.OnFilter = "[PROJ_ID]='6000'"
> > > >
> > > > End Sub
> > > >
> > > >
> > > > I've also tried...
> > > >
> > > > Private Sub Form_Open(Cancel As Integer)
> > > >
> > > > Me.Filter = "[PROJ_ID]='6000'"
> > > >
> > > > End Sub
> > > >
> > > >
> > > > Instead, I still see all projects listed in the data***. What am I doing
> > > > wrong and what code should I use to filter out just the one project?
> > > >
> > > > Sincerely,
> > > > Dirk
> > > >
> > > > North/South Consultants Inc.
> > > > Winnipeg, Canada
> > > >
.


Quantcast