A family of Microsoft relational database management systems designed for ease of use.
Instead of
strField & " = 'strValue'"
use
strField & " = '" & strValue & "'"
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I'm trying to create a procedure on the double click event of a text box to open a form in datasheet view of all records with a matching field value. For this I've tried creating two variables to store the field and value for the filter criteria, but when I tried substituting these into my filter string I got an error #3085.
This is the code I have in my OnLoad event of the datasheet I want returned:
Private Sub Form_Load()
If IsNull(strValue) Then
Me.FilterOn = False
Else
Me.Filter = "" & strField & " = '" & strValue & "'"
Me.FilterOn = True
End If
End Sub
The error #3085 description I get is:
"Undefined function 'tblSelfContained.Fields' in expression."
I tried using 'tblSelfContained.Fields(strField)' in my filter string but since removed it and yet am still getting the error.
Anybody got any idea as to why?
Much appreciated,
Seb
A family of Microsoft relational database management systems designed for ease of use.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Answer accepted by question author
Instead of
strField & " = 'strValue'"
use
strField & " = '" & strValue & "'"
Also; just realised that access claims the error is happening on the dbl click event of the textbox.. I commented out the whole on load procedure and I'm still getting the exact same error..
Here's the code for the dbl click event:
Private Sub txtWeight_DblClick(Cancel As Integer)
strField = "Weight"
strValue = Me.txtWeight
DoCmd.OpenForm "frmSelfContainedSorted"
End Sub
Apparently the error occurs on the line "DoCmd.OpenForm "frmSelfContainedSorted"
And I've checked my references, none are missing..
Hi, try with
Me.Filter = """" & strField & " = '" & strValue & "'"""
Ciao Mimmo
The value is "Weight"
What is the value of strField when the error occurs?