The debugger is still coming up with the error "Object doesn't support
this
property or method". DUPL is on the form, but I check the table to be
sure.
The formula is returning a value of 0 (I had it temporarily display the
result in a comment field), so the falue is not NULL. When it gets to
Else: DUPL = True
this error pops up.
I had it looking like
Else
DUPL=True
and received the same error.
I even tried BEGIN and END
Curent state of the code:
Private Sub INPUT_NUMBER_AfterUpdate()
COMMENTS = IsNull(DLookup("[ID]", "tblResumes", "AREA_CODE =
Forms!frmInputting!AREA_CODE and INPUT_NUMBER =
Forms!frmInputting!INPUT_NUMBER"))
If IsNull(DLookup("[ID]", "tblResumes", "AREA_CODE =
Forms!frmInputting!AREA_CODE and INPUT_NUMBER =
Forms!frmInputting!INPUT_NUMBER")) Then
'If IsNull(DLookup("[YourKeyField]", "YourTableName", "AreaCode =
Forms!frmYourFormName!AreaCode and InputNumber =
Forms!frmYourFormName!InputNumber")) Then
' Beep
DUPL = False
Else
DUPL = True
End If
End Sub
Al Camp said:
Rod,
I had reversed the True/False logic in my original post... , and an
extra
" was inserted. Apologies.
It should have been... (the IF is all on one line)
If IsNull(DLookup("[YourKeyField]", "YourTableName", "AreaCode =
Forms!frmYourFormName!AreaCode and InputNumber =
Forms!frmYourFormName!InputNumber")) Then
Beep
Duplicate = False
Else
Duplicate=True
End if
That's why I said to check out my syntax... writing code in emails is
prone to typos.
In one of your subsequent posts, you wrote...
To be sure, I looked at tblResume and found the flags on the duplicates
were not set.
Is the field Duplicate on your form? It should be... The Duplicate =
True/False code assumes the field is on the form where you are entering
your
phone numbers... so you shouldn't have had to go to a table to see if it
was
set or not.
Also, you have Douglas Steele's solution now... give that a shot
too...
you may find that easier.
hth
Al Camp
After trying:
If Not IsNull(DLookup("[ID]", "tblResumes", "AREA_CODE =
Forms!frmInputting!AREA_CODE And INPUT_NUMBER =
Forms!frmInputting!INPUT_NUMBER")) Then
'Beep
DUPL = True
'Else
' DUPL = False
End If
End Sub
I get "Object doesn't support this property or method" when I exit
INPUT_NUMBER. The debugger highlights the "DUPL = True" line.
:
Rod,
Since you would enter AreaCode and then Input_Number, I would use
the
After Update event of Input_Number to run a Dlookup for a duplicate
record.
Each of your records should have a unique "key" value such as a
RecordID,
or
Customer ID, etc... so run the Dlookup against that field.
I prefer to use AfterUpdate, because it leaves the entered number
visible, so the user can check their entry, before retrying.
If IsNull(DLookup("[YourKeyField]", "YourTableName", "AreaCode =
"Forms!frmYourFormName!AreaCode and InputNumber =
Forms!frmYourFormName!InputNumber")) Then
Beep
Duplicate = True
Else Duplicate=False
End if
Check my code/syntax for typos... but that should do it.
hth
Al Camp
I have "NUMBER" which are area codes and phone numbers combined to
look
like
8471234567. New records are added to tblResume by:
1) frmInputting, which has txtbxINPUT_NUMBER and option group
AREA_CODE.
2) txtbxINPUT_NUMBER is just the seven digit phone number.
3) NUMBER is created by AREA_CODE & txtbxINPUT_NUMBER
Every time txtbxINPUT_NUMBER is exited, I'd like to confirm that
there
is
no
other copy of "txtbxINPUT_NUMBER & AREA_CODE" in the list. If a
copy
is
found, DUPLICATE should be set to True, else false for that record.
Thanks