Solved Runr time error 3008

atrium

Registered User.
Local time
Today, 21:59
Joined
May 13, 2014
Messages
348
I have a Parent Form (Orders) and a sub form (OrdersSubform) The parent displays details of the Order and the subform displays details about the relative Items on that order. That's all fine.
I want to create a number of search options
The first one is to change the parent order. I currently have the search option field on the parent form and the code is:-
Code:
Private Sub tbFilterOrderNumber_Change()
    Dim strNewRecord As String
    strNewRecord = "SELECT * FROM Orders " _
    & " WHERE OrderNumber = " & Me.tbFilterOrderNumber
    Forms.OrdersFrm.Form.RecordSource = strNewRecord
End Sub
On the last line above the End Sub above I get the following Runtime error

1588806275129.png

I have also created another subform on the parent form and put the search options in there. The same thing happens.
I have other forms that that do the same thing but to a subform and they work

Any help would be appreciated
 
Last edited by a moderator:
I'd use the after update rather than the change event, which fires with every keystroke and requires you to use the .Text property. You may not be getting a value from that textbox.
 
Thanks pbaldy I changed the code to

Private Sub tbFilterOrderNumber_AfterUpdate()
Dim strNewRecord As String
strNewRecord = "SELECT * FROM Orders " _
& " WHERE OrderNumber = " & Me.tbFilterOrderNumber.Text
Forms.OrdersFrm.Form.RecordSource = strNewRecord
End Sub

and got the same result
 
Can you attach the db here? I've changed the recordsource property many times and not had this issue. I assume no other form has locked that table. Oh, and try

Me.RecordSource = strNewRecord

if the code is on the same form. If not I think it's bang not dot, though I'm not sure it matters:

Forms!OrdersFrm.RecordSource = strNewRecord
 
It's OK now.
It was 'all Records' locked.

Thanks for everything (y) :)
 
Glad you found the issue.
 

Users who are viewing this thread

Back
Top Bottom