Hi all
i have a textbox [LeBayNum] on a Sub Form [frmllisteditems subform]
bound to a table [tblListedItems]
i want to make sure there are no duplicate eBay numbers entered in the
textbox
so here is my code in the before update event procedure of the textbox
LeBayNUM
On Error GoTo errorhandler
Dim Cnn As ADODB.Connection
Dim Rst As ADODB.Recordset
Set Rst = New ADODB.Recordset
Dim response As Integer
If (Me![LeBayNUM] <> Me![LeBayNUM].OldValue) Or
IsNull(Me![LeBayNUM].OldValue)_ Then
Cnn.Open CurrentProject.Connection
Rst.Open "SELECT * from TblListedItems where [LeBayNUM]= """ &
Me!LeBayNUM &_ """", Cnn, adOpenForwardOnly, adLockReadOnly
If Not Rst.EOF Then
response = MsgBox("Duplicate eBay Number!" & vbCrLf & "Do You want to
Cancel_ the Entry?", vbYesNo + vbCritical, "Duplicate eBay Number")
If response = vbYes Then
[LeBayNUM].Undo
End If
End If
Rst.Close
Set Rst = Nothing
End If
GoTo done
Set Rst = Nothing
GoTo done
errorhandler:
MsgBox Err.Description
done:
End Sub
the error message that i get every time the code is executed is
Object variable or With block variable not set
any help will be appreciated
thank you in advance