Applying filter when opening form

jammin140900

Registered User.
Local time
Today, 21:39
Joined
Aug 18, 2008
Messages
35
Hi all,

I have a form and a subform, with a button on the form to select the current subform (frmEvents) ChecklistID and open another form (frmReceipts) where the ChecklistID's match. (This field is common to both tables where ChecklistID is a one to many relationship between frmEvents and frmReceipts respectively.

That all works great. The form frmReceipts opens with the current ChecklistID that was displayed in the frmEvents area. The problem is that the filter only seems to apply to open the form. Once it is open, ChecklistID for any new entry in frmReceipts = 0 and not the same ChecklistID.

I can only think that you require more code to keep the filter on so that any entries in frmReceipts will still hold the same ChecklistID that it opened with.

Anyone have any ideas of the code? Is it something like DoCmd.ApplyFilter......(something like that?) .Perhaps it is placed on a particular property such as "On load" of the form? Not sure..

Help very appreciated. Thank you,

Jammin
 
I think you need to set the controls default value to ChecklistID in the primary form (or subform in this case) -

Will this work?
 
Not sure what you mean Ken. How would I do that?
 
In the second form put something like the following in the forms OnOpen event:

me.MyTextBox.DefaultValue = forms!myMainForm!mySubForm.form!myTextBox

???
 
Ken, you are a genius! Thanks heaps.. It has been frustrating me for ages..
 
Ken, I just noticed that you can enter the data, but when you close and reopen the form, all but the first piece of data you entered disappear. Any ideas?
 
I'm guessing that at this point when you open the second form the intention is add a new record, in which case it seems all you want is the default value to be pre-populated - ?
 
Ok, a little confused..

I have a frmReceipts and subform frmReceiptsSub when now open with a checklistID from the previous form correctly and stay with the same ChecklistID for any additional entries in the frmReceiptsSub which is perfect.

The only problem is that when if I close and re-open the frmReceipts (in which the frmReceiptsSub also opens in datasheet view at the same time obviously), only the first entry in the subform datasheet is seen and all the other entries that were inputed before closing and reopening have disappeared. They do hit the tables though, just not to be seen on the subform.

That makes sense?
 
Does frmReceipts have the checklistID field?
 
Yes.. They are running off the same table, tblReceipts. The only reason for the Receipt form and subform is to look tidy. The subform is datasheet view and wrapping it into a form looks neater.
 
Then that is where you need to set the default value. And in the the subform you simply need to make sure you have the master/child fields set up correctly between the form and the subform control....
 
Oh mate, you are a champ.. That was what was wrong. When I created the form and subform, I just dragged and dropped it in without thinking of the linking fields between the forms. That's why all the hassles. I've been staring at this for over 4 hours today. A fresh pair of eyes was a blessing! Thanks for your time mate.
 

Users who are viewing this thread

Back
Top Bottom