Apply a DoCmd command to a different form

RCurtin

Registered User.
Local time
Today, 10:14
Joined
Dec 1, 2005
Messages
159
Hi,
OK my main form is unbound and I have a subform in it which is shown as a datasheet. What I'm trying to do is have a list box control at the top that allows the user to filter the records shown in the subform.

Q1. Do I need to have this set-up like this? Is it possible to just use one form? I have tried doing this but when I add my list box, lables etc to the top of the form or the header they just do not appear in datasheet view.

Q2. If I do need to use a subform how do I reference it when using DoCmd.ApplyFilter from my main form:

Code:
DoCmd.ApplyFilter , "DrawingNum = '32-35612'"

At the moment this gives an error saying that the action or method is invalid because the form is unbound.

Thanks for your time,
RCurtin
 
You could do it all on one form.

Create a 2nd massive list box that holds everything you would otherwise put in your datasheet. The source for the 2nd list box is reliant on the selection of the 1st list box.

Create an after update event procedure for the 1st list box that has

2ndlist.requery
2ndlist.setfocus
 
Hi Jibbadiah,
Thanks for that. I have tried that and it looks great. The only thing is I will need to filter the items in the listbox in different ways. For instance I will need to show all drawings issued after a certain date, all superceded drawings or the latest revisions.. I would also like the user to be able to select a drawing by clicking on a checkbox next to it. (Basically I want to do something like the North Wind Database.) Will this be possible with the records in a listbox?

Therefore it the records shown (depending on the users selections) will be based on several different fields in the underlying query.

Is this possible to do using a listbox?
Thank you,
RCurtin.
 
Error with filters

OK, I've actually changed it now - I'm using a continuous form instead - didn't know you could do that.
It makes more sense in my case as the main form was not bound to the subform - it was not necessary for it to be a subform at all.

I'm getting a different error now when I try to apply a filter. Here is the code:

Code:
Me.Filter = "DrawingStatus = 'Latest Revision'"
Me.FilterOn = True

It generates an error with the number 0. It doesn't say anything else. It does actually filter the records but always generates this error. Any ideas anyone?




Thanks for your help,
RCurtin.
 

Users who are viewing this thread

Back
Top Bottom