Hi.
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.
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.