Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database engine does not recognize text field as a valid expression

Status
Not open for further replies.

dzavad

Programmer
Apr 17, 2000
167
0
0
US
Hi,
I have a form "Reports" that contains list box from which user has an option of multi-select choises which needs to be passed into the Query as the parameter for the were clause condition.
"Where [User Name] in [Forms]![Reports]![lst_Auditor]". The result of this query is the Access report

What is the best way to do this?

I extracted chosen values but not sure now to pass it to the query. From the example below I was passing the result to the hiden textbox on the same form [text_Auditor] and then adding the text box to the query condition [Forms]![Reports]![Text_Auditor]. But I am getting the error "The Microsoft Access database engine does not recognize [Forms]![Reports]![Text_Auditor] as a valid field name or expression. (Error 3070)"

Private Sub cmdApplyFilter_Click()
Dim varItem As Variant
Dim strAuditor As String
Dim strFilterAU As String

' Build criteria string from Auditor listbox
For Each varItem In Me.Auditor.ItemsSelected
strAuditor = strAuditor & ",'" & Me.Auditor.ItemData(varItem) _
& "'"
Next varItem
If Len(strAuditor) = 0 Then
strAuditor = "Like '*'"
Else
strAuditor = Right(strAuditor, Len(strAuditor) - 1)
strAuditor = "IN(" & strAuditor & ")"
'strAuditor = strAuditor
End If

' Build filter string
strFilterAU = strAuditor

With Forms!Reports!Text_CM
.SetFocus
.Text = strFilterCM
End With


I also have date range text boxes on the same for which I was able to pass to the query :
Between DateValue([forms]![reports]![from_date]) And DateValue([forms]![reports]![thru_date])

What am I doing wrong?
 
What about this format:
Code:
 [Forms]![Reports][b][red].[/red][/b][Text_Auditor]

Greg
People demand freedom of speech as a compensation for the freedom of thought which they seldom use. Kierkegaard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top