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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

invalid field name or expresstion

Status
Not open for further replies.

jmnekrkt

Programmer
Feb 21, 2002
47
US
the following code is in two reports

If Forms![misc reports].chkSelectSection = -1 Then
Me.Filter = "unit = forms![misc reports].txtSection"
Me.FilterOn = True
Else
Me.FilterOn = False
End If

In one report, the filter allows only the selected section to print. In the other report, I receive the error

"The microsoft jet engine does not recognize 'forms![misc reports].txtSection' as a valid field name or expression".

If I manually enter the text value and turn on the filer it works. It just will not read it from the other form.

Any suggestions???

Thank you
 
You'll have to pull the criteria out of the quotes, like this:
Me.Filter = "unit = '" & forms![misc reports].txtSection & "'"

Access has to evaluate the expression before passing the sql to Jet (the database engine).

Note that I've put in single quotes here, to offset what I am _guessing_ is a string in your text box. If it's numeric, get rid of the single quote after the equals sign and the & "'" at the end.

Jeremy
=============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developer's section of the site for some helpful fundamentals.
 
Thank you both for responding. This question actually got double posted and was resolved under the other post...with practically the same solution.
 
Yeah, that's a drag. PLEASE do not double post questions. It means that people like me waste time answering questions that have already been answered. It's only polite to post to only one forum.

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developer's section of the site for some helpful fundamentals.
 
Thank you for the location. I did not intentionally double post...the site hung up and then failed...there was no evidence that the first submit was successful until I saw both posted. If there is a way to delete erroneous posts, please advise for future reference.

 
Oh. I thought you were saying it was posted in two different forums.

Yeah, that stuff happens.

Sorry. =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developer's section of the site for some helpful fundamentals.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top