I'm rather surprised that no error occurred. A few problems here:
1. The = sign should be within the literal string expression.
2. Using Name as field name is not a good idea as it can conflict with the
Name property of an object. Something like ContactName, CompanytName etc, is
better. If you do use Name then wrap it in square brackets when referring to
it in the code.
3. Put the code in the combo box's AfterUpdate event procedure, not its
Click event procedure.
4. You have too many quotes characters in places. You should have one set
of quotes characters around each literal string, and pairs of adjacent quotes
characters within the literal strings to represent a quotes character within
a literal string itself delimited by quotes.
5. Not essential, but breaking up the code with blank lines helps
readability. Similarly leaving a space between an operator (e.g. = or &) and
its operands improves readability.
So the code would
Dim strCriteria As String
strCriteria = "[name] = """ & Me.txtName & """"
If Not IsNull(DLookup("[name]", "qscale06", strCriteria)) Then
DoCmd.OpenReport "rscaletickets06", WhereCondition:=strCriteria
Else
MsgBox "Name not found", vbInformation, "Warning"
End If
Ken Sheridan
Stafford, England
rkg said:
Ken, Here is what I did. I added a combo box that brings up all the
names then added this code to the click event procedure:
Dim strCriteria As String
strCriteria = "name" = """&Me.txtName&"""""
If Not IsNull(DLookup("name", "qscale06", strCriteria)) Then
DoCmd.OpenReport "rscaletickets06", WhereCondition:=strCriteria
Else
MsgBox "Name not found", vbInformation, "Warning"
End If
I got no error messages but when I try to choose a name from the combo
box I can't.
Thanks for any help you could offer.
Ron Greenbank