Error in Code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to avoid duplication while I enter my order, if I try to add a number
which is already available in table, then a message should show that the
number exist.

Table name = Orders
Field in table = OrdNo ( Order sample : QTNNo/256,QTNNo/257 etc..

Form name :OrderEntry
Control name in Form : Text20

I've got a code for this purpose, but it shows "Expected list seperator"

here is the code

please correct this code

If DCount("[OrdNo]"," Orders ","[ OrdNo] ='"Forms! OrderEntry!Text20& "'")
<>0 Then
MsgBox "....Duplicate"
Cancel = True

Thanks
 
Hi AN,
It looks like that you are missing white space in between operator. I will
try to give you something that you can copy and paste cleanly.

Dim Tmp_Ctr as integer

Tmp_Ctr = DCount("OrdNo", "Orders", "OrdNo = '" &
[Forms]![OrderEntry]![Text20] & "'")
If Tmp_Ctr <> 0 then
MsgBox "....Duplicate"
Cancel = True
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top