Type Mismatch; Object Required

  • Thread starter Thread starter EdwardA
  • Start date Start date
E

EdwardA

At first, second, and third glance my code looks solid.
Statement > Open form where part number = text box or
where alternate part number = text box. Something is
obviously missing though.

Any takers?

Heres my code:

Private Sub Command3_Enter()
On Error GoTo Err_Command3_Enter

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "PARTS_WHSE27"

stLinkCriteria = "[Part Number]" & "'" & Me![Text1]
& "'" Or "[Alternate Part Number]" & "'" & Me![Text1] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

DoCmd.RunCommand acCmdTileHorizontally

Exit_Command3_Enter:
Exit Sub

Err_Command3_Enter:
MsgBox Err.Description
Resume Exit_Command3_Enter

End Sub
 
I can see that you where condition is incomplete:
stLinkCriteria = "[Part Number]=" & "'" & Me![Text1] & "'" Or "[Alternate
Part Number]=" & "'" & Me![Text1] & "'"

The malformed where condition is probably causing the form not to load and
the error is caused/raised by the next statement:
DoCmd.RunCommand acCmdTileHorizontally

See if this fixes the problem.


Also ([probably] unrelated to the problem), I think you're using the Enter
event of a command button, don't you mean to use the Click event?
 
Back
Top