Compile error

Local time
Today, 11:46
Joined
Feb 14, 2025
Messages
33
Hi All

I have an unbound form with a subform in it in continuous form layout.

The subform lists a query with all products along with the product category. In the subform header area I have a combi box which lists each category, the idea being the user can select a category and the continous records filter to that category.

I am trying to use the after update event to run the following;

Code:
Private Sub PetFilter_AfterUpdate()

Dim strSQL As String

    strSQL = "PetTypeID = " & Me.PetFilter


    Me.CustSaleProductSelectFM.Form.Filter = strSQL

    Me.CustSaleProductSelectFM.Form.FilterOn = True



End Sub

PetTypeID is the primary key for the category and is a number.
CustSaleProductSelectFM is the subform name and control name on the form.

When the event runs, I get a compile error - "Method or data member not found" and the me.CustSaleProductSelectFM.filter=strSQL line is highlighted yellow in the debugger.

Strangely, on a separate from I have similar code filtering customers by postcode or surname triggered by a command button and it works great.

What am I doing wrong.

Thanks in advance
 
Try simply:

Me.Filter=strSQL
 
Hi
Yes, I do usually do use the master/child fields on my subform but on this form and subform there is no linked data.

I will have another subform which stores the items purchased on the transaction which will relate to the individual transaction and will be linked using master/child.

This subform is a way to filter products quicker for selection

Thanks
 
Yes, I do usually do use the master/child fields on my subform but on this form and subform there is no linked data.
What I was saying is you can link the subform data to the data in the combobox.
 
in the subform control set the link master property to petfilter and link child to pettypeid
 
I'm going to ask a silly question, but something you said doesn't seem right. From your first post in this thread, ...

I have an unbound form with a subform in it in continuous form layout.

Update and certain other events do not occur for unbound forms unless you are manually calling the event routines by name. Parent/child form relationships cannot occur unless the sub-form control's parent and child links are related to bound fields or unless you bind that linkage to an unbound field that will manually drive the navigation of the sub-form. And I'm not going to swear that it would work for the unbound case.

Therefore, I have to ask: Do you REALLY have an unbound parent form? Or did you mean something else?

When the event runs, I get a compile error - "Method or data member not found"

Again, this is either a nomenclature error or something odd is happening. An event won't GET to run (or it might not run correctly) if you actually have a compile error. That error is possible as a run-time error if you try to name a property that doesn't exist for the given object even if it DOES exist for some objects.
 
Last edited:
Hi
I should clarify
The main form has two subforms, one being a child of the main form. ie. main form is transactions and subform is items in that transaction.

The form with no parent/child relation is just a list of all products with just a filter box to shorten the list and quicken selection. Once the required item is found and a button pressed it should make the new child record.

Thats the aim
 

Users who are viewing this thread

Back
Top Bottom