Error Extra ) in Query expression

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a subform that is inform of a data sheet, if I click on an empty line
and click the preview button, it gives me the error

Extra ) in query expression '(EmployeeID=)'

Why does occur, and how can get rid of it. This by the way only occurs when
I click on the empty line, but a line that has information I can click
preview and the report will come up.
 
Hi.
Why does occur

It occurs because there's no value to assign to EmployeeID, so the equation
gets a "blank" value, or NULL. The closing parenthesis is the next character
evaluated in the equation, not a number, so this is interpreted as a
misplaced or "extra" parenthesis.
how can get rid of it.

Have the code check for the NULL value before attempting to open the report,
and skip the opening of the report if there's no EmployeeID to assign before
opening the report. For example:

If (Nz(Me!txtEmployeeID.Value, 0) <> 0) Then
DoCmd.OpenReport "MyRptName", acViewPreview, , _
"(EmployeeID = " & Me!txtEmployeeID.Value & ")"
Else
MsgBox "There is no record to preview.", vbInformation, "No Record"
End If

.... where MyRptName is the name of the report to be opened and txtEmployeeID
is the name of the text box holding the EmployeeID value. This example uses
0 to compare against for the NULL value since this number is not expected in
an AutoNumber, but you must decide what an invalid value is in your table and
use that instead of 0 if you are not using an AutoNumber.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
Beware to those who use munged addresses: known newsgroup E-mail harvesters
for spammers are (e-mail address removed) and (e-mail address removed)

- - -
When you see correct answers to your question posted in Microsoft's Online
Community, please sign in to the Community and mark these posts as "Answers,"
so that all may benefit by filtering on "Answered questions" and quickly
finding the right answers to similar questions. Remember that questions
answered the quickest are often from those who have a history of rewarding
the contributors who have taken the time to answer questions correctly.
 
"JOM".

JOM said:
I have a subform that is inform of a data sheet, if I click on an empty
line and click the preview button, it gives me the error:
'Extra ) in query expression '(EmployeeID=)'

What "preveiw button"?
Why does occur, and how can get rid of it. This by the way only occurs
when I click on the empty line, but a line that has information I can
click preview and the report will come up.

So you have a form that contains a subform and you have a command
button on the main form that should open a report to display information
about the current record selected in the subform?
Does the main form contain data when this happens?
What does the code/marcro look like?
Why do I have more questions than you?
 
have unbound form with unbound txtbox(cboDaily), and 2 txtboxes
(txBeginDate) and txEndDate. and command OK

I select an employee from the combox then input the begin and end date,
click ok and its supposed to open a report
however if there is no data for that employee during that date range, I
receive the following error
Microsoft Jet Databases Engine does not recogniz " as a valid field name or
expression

How will I take care of this
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top