Query from Sub-Form

bleakhouse

New member
Local time
Today, 21:26
Joined
Mar 7, 2019
Messages
14
Hi

I think that I have asked this question before but I cannot find or remember the solution. I hope that someone can point me in the right direction.

I have a query to find items in a table, my form and the sub-form is created from a query as I have used may times before by copying the code.

This time it does not work and gives an error message, I have listed the code and error below.

Any help would be gatefully recieved.

Dim SQL As String
Dim SearchItem As String
Dim RecsetLI As Recordset

InitialSearch:

SearchItem = InputBox("Enter Item to search for")
SearchItem = Item + "*"

SelectItem:

SQL = "SELECT * from libraryitems where SearchItem like '" & Item & "'"

Me.dataDisplaySubform.Form.RecordSource = SQL
Me.dataDisplaySubform.Requery
Me.dataDisplaySubform.Visible = True
Me.SelectR.Visible = True
Exit Sub

The form is a standard form with a button and the sub-form is made by dropping the query onto the form in design mode.

The error message states Compile error, method or data member not found

Thanks in anticipation

Regards

Ian Clegg
 
It would be helpful to identify which line of code gets highlighted. However, I'm going to guess that it might be one or both of these two:

Code:
Me.dataDisplaySubform.Requery
Me.dataDisplaySubform.Visible = True

If you thought you needed the .Form after the sub-form control's name to load the .RecordSource, why would you omit it from the next two lines that ALSO relate to doing something to the contained form (as opposed to doing something with the sub-form control)?
 
You have no * with your Like ?
Please use code tags for code. :(

Also you could identify which line the error occurs on?, that always helps.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom