Hello! I'm still rather new to using code in access. I've come across
a problem that I'm having difficulty troubleshooting. Any assistance
would be greatly appreciated!
I've set up a form where an order number is entered. I have entered
code where if an order number is entered that is a duplicate, a message
box will pop up and tell you so that you can change the number. The
code works perfect for telling you if there's a duplicate or not.
The problem I'm having is that if someone mistakenly types in
information they didn't mean to go to that field and try to delete it
out it bombs. I get an error that says Run-time error '-2147217900
(90040e14)' Syntax error (missing operator) in query expression
'OrderNo='. Then asks me to end or debug. I'll paste the code below.
If anyone has any suggestions or ideas I'd appreciate it!
Private Sub txtOrderNo_BeforeUpdate(Cancel As Integer)
Dim rs As New ADODB.Recordset
rs.Open "SELECT * FROM tblInbDiscrepancyLog WHERE OrderNo=" &
txtOrderNo, CurrentProject.Connection, adOpenStatic, adLockReadOnly
If rs.RecordCount 0 Then
MsgBox "Warning Order Number " _
& Me.txtOrderNo.Value & " has already been entered." _
& vbCr & vbCr & "Please enter a different order
number.", vbInformation _
, "Duplicate Information"
End If
End Sub