Find Duplicate Number

G

Guest

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
 
A

Al Camp

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
 
D

Douglas J. Steele

You can use the DCount function in the AfterUpdate event of
txtbxINPUT_NUMBER:

If DCount("*", "tblResume", "[Number] = '" & AreaCode & txtbxINPUT_NUMBER &
"'") > 0 Then
Duplicate = True
Else
Duplicate = False
End If

However, you indicated that AreaCode is an option group, which means that
you're only going to get a selection number (1, 2, 3), rather than an area
code (416, 647, 905). You can use Choose function to translate:

If DCount("*", "tblResume", "[Number] = '" & _
Choose(AreaCode + 1, "416", "647", "905") & _
txtbxINPUT_NUMBER & "'") > 0 Then
Duplicate = True
Else
Duplicate = False
End If
 
G

Guest

I think this is close. I received a Compiler error:
Wrong number of arguments or invalid property assignment

The code is:
Private Sub INPUT_NUMBER_AfterUpdate()
If 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

Al Camp said:
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

Rod said:
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
 
G

Guest

I tried the following to help debug:
Private Sub INPUT_NUMBER_AfterUpdate()
If 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

the form still allows me to enter a duplicate number. I was expecting if I
enter 1234567 with the defualt option group AREA_CODE of 847 it would find
other 8471234567 numbers and set DUPL. To be sure, I looked at tblResume and
found the flags on the duplicates were not set.

Al Camp said:
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

Rod said:
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
 
G

Guest

After entering the following before the IF statement
COMMENTS = DLookup("[ID]", "tblResumes", "AREA_CODE =
Forms!frmInputting!AREA_CODE And INPUT_NUMBER =
Forms!frmInputting!INPUT_NUMBER")
It is returning the record ID of the first duplicate record. All i want it
to do is set DUPL to true.

Al Camp said:
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

Rod said:
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
 
G

Guest

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.

Al Camp said:
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

Rod said:
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
 
A

Al Camp

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

Rod said:
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.

Al Camp said:
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

Rod said:
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
 
G

Guest

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

Rod said:
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.

Al Camp said:
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
 
A

Al Camp

Rod,
I built a table with 2 number fields... Number1 and Number2. I populated
the table with
Number1 Number2
1 1
2 2
3 3 etc... etc...

On a form I place two unbound fields named N1 and N2 so I could enter 2
numbers and see if my table contained an entry that contained both numbers.
I then added an unbound text control with this RecordSource... (just for
now ditch the Comments= part of the code)
=IIf(IsNull(DLookUp("[Number1]","tblNumbers","[Number1]=[Forms]![frmNumbers]![N1]
And [Number2]=[Forms]![frmNumbers]![N2]")),"Does Not Exist","Does Exist")

If I entered 1 and 1 I got "Does Exist".
If I entered 1 and 9 I got "Does Not Exist"
So... I have to say... the IIF logic part of the code is OK, and you have
some other problem.

*What line in your code did the Debug point to?*
*Can you do ANY OTHER Dlookup at all?*
*Are both AreaCode and InputNumber Number fields?*
*Is Dupl a Boolean type?*
and
*Have you tried Douglas's solution?*

Hang in there...
Al Camp

Rod said:
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

Rod said:
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
 
G

Guest

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

Debugger is pointing to "DUPL = True".
DLookup appears to be working fine.
AREA_CODE and INPUT_NUMBER are both text fields
DUPL is a boolean of format True/False
I have not tried Douglas's solution yet. I got started with yours and
wanted to give it another swing.

Thanks

Al Camp said:
Rod,
I built a table with 2 number fields... Number1 and Number2. I populated
the table with
Number1 Number2
1 1
2 2
3 3 etc... etc...

On a form I place two unbound fields named N1 and N2 so I could enter 2
numbers and see if my table contained an entry that contained both numbers.
I then added an unbound text control with this RecordSource... (just for
now ditch the Comments= part of the code)
=IIf(IsNull(DLookUp("[Number1]","tblNumbers","[Number1]=[Forms]![frmNumbers]![N1]
And [Number2]=[Forms]![frmNumbers]![N2]")),"Does Not Exist","Does Exist")

If I entered 1 and 1 I got "Does Exist".
If I entered 1 and 9 I got "Does Not Exist"
So... I have to say... the IIF logic part of the code is OK, and you have
some other problem.

*What line in your code did the Debug point to?*
*Can you do ANY OTHER Dlookup at all?*
*Are both AreaCode and InputNumber Number fields?*
*Is Dupl a Boolean type?*
and
*Have you tried Douglas's solution?*

Hang in there...
Al Camp

Rod said:
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
 
G

Guest

I receive the error:" The expression After Update you entered as the event
property setting produced the following error: Invalid outside procedure."
This error appears when I exit the INPUT_NUMBER field. DUPL is on the form
and is never set to true (it is represented as a cleared checkbox).

DUPL is boolean of type yes/no formatted as true/false. Its control source
is DUPL
Control source for INPUT_NUMBER is INPUT_NUMBER. Even if I put a unique
number in INPUT_NUMBER I get the same error.

The code looks like this:
Private Sub INPUT_NUMBER_AfterUpdate()

If DCount("*", "tblResumes", "[Number] = '" & AREA_CODE & INPUT_NUMBER &
"'") > 0 Then

DUPL = True

Else

DUPL = False

End If

End Sub


My option buttons have default values corresponding to the appropriate area
code, i.e. button 847 has a value of 847.

Douglas J. Steele said:
You can use the DCount function in the AfterUpdate event of
txtbxINPUT_NUMBER:

If DCount("*", "tblResume", "[Number] = '" & AreaCode & txtbxINPUT_NUMBER &
"'") > 0 Then
Duplicate = True
Else
Duplicate = False
End If

However, you indicated that AreaCode is an option group, which means that
you're only going to get a selection number (1, 2, 3), rather than an area
code (416, 647, 905). You can use Choose function to translate:

If DCount("*", "tblResume", "[Number] = '" & _
Choose(AreaCode + 1, "416", "647", "905") & _
txtbxINPUT_NUMBER & "'") > 0 Then
Duplicate = True
Else
Duplicate = False
End If


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Rod said:
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
 
G

Guest

Could this error be coming from the fact that DUPL is of format True False
and perhaps the DLOOK function is not returning the result in a compatable
format? If so, how do we get it in a compatable format?

Rod said:
I receive the error:" The expression After Update you entered as the event
property setting produced the following error: Invalid outside procedure."
This error appears when I exit the INPUT_NUMBER field. DUPL is on the form
and is never set to true (it is represented as a cleared checkbox).

DUPL is boolean of type yes/no formatted as true/false. Its control source
is DUPL
Control source for INPUT_NUMBER is INPUT_NUMBER. Even if I put a unique
number in INPUT_NUMBER I get the same error.

The code looks like this:
Private Sub INPUT_NUMBER_AfterUpdate()

If DCount("*", "tblResumes", "[Number] = '" & AREA_CODE & INPUT_NUMBER &
"'") > 0 Then

DUPL = True

Else

DUPL = False

End If

End Sub


My option buttons have default values corresponding to the appropriate area
code, i.e. button 847 has a value of 847.

Douglas J. Steele said:
You can use the DCount function in the AfterUpdate event of
txtbxINPUT_NUMBER:

If DCount("*", "tblResume", "[Number] = '" & AreaCode & txtbxINPUT_NUMBER &
"'") > 0 Then
Duplicate = True
Else
Duplicate = False
End If

However, you indicated that AreaCode is an option group, which means that
you're only going to get a selection number (1, 2, 3), rather than an area
code (416, 647, 905). You can use Choose function to translate:

If DCount("*", "tblResume", "[Number] = '" & _
Choose(AreaCode + 1, "416", "647", "905") & _
txtbxINPUT_NUMBER & "'") > 0 Then
Duplicate = True
Else
Duplicate = False
End If


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Rod said:
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
 
A

Al Camp

Rod,
Well, there has to be a problem with the Dupl field....
Is it included in the query behind the form?
Is it bound to the Dupl field... in the ControlSource for the Dupl field
on the form do you have Dupl (no quotes, and not =[Dupl], or anything
else... just Dupl )?
To be sure, when you use the ControlSource property dropdown to select a
field to bind it to... is Dupl on the list?

If you don't find the problem with Dupl, I would think Douglas's code
will not work either.

Also, if you still can't find the problem, remove Dupl from the form and
reinstall it right back. That will set all Dupl properties back to
default... formatting, validation, etc...etc...

hth
Al Camp

Rod said:
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

Debugger is pointing to "DUPL = True".
DLookup appears to be working fine.
AREA_CODE and INPUT_NUMBER are both text fields
DUPL is a boolean of format True/False
I have not tried Douglas's solution yet. I got started with yours and
wanted to give it another swing.

Thanks

Al Camp said:
Rod,
I built a table with 2 number fields... Number1 and Number2. I
populated
the table with
Number1 Number2
1 1
2 2
3 3 etc... etc...

On a form I place two unbound fields named N1 and N2 so I could enter
2
numbers and see if my table contained an entry that contained both
numbers.
I then added an unbound text control with this RecordSource... (just
for
now ditch the Comments= part of the code)
=IIf(IsNull(DLookUp("[Number1]","tblNumbers","[Number1]=[Forms]![frmNumbers]![N1]
And [Number2]=[Forms]![frmNumbers]![N2]")),"Does Not Exist","Does Exist")

If I entered 1 and 1 I got "Does Exist".
If I entered 1 and 9 I got "Does Not Exist"
So... I have to say... the IIF logic part of the code is OK, and you have
some other problem.

*What line in your code did the Debug point to?*
*Can you do ANY OTHER Dlookup at all?*
*Are both AreaCode and InputNumber Number fields?*
*Is Dupl a Boolean type?*
and
*Have you tried Douglas's solution?*

Hang in there...
Al Camp

Rod said:
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


:

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
 
G

Guest

Got it resolved.

THANKS MUCH FOR YOUR SUPPORT!

Douglas J. Steele said:
You can use the DCount function in the AfterUpdate event of
txtbxINPUT_NUMBER:

If DCount("*", "tblResume", "[Number] = '" & AreaCode & txtbxINPUT_NUMBER &
"'") > 0 Then
Duplicate = True
Else
Duplicate = False
End If

However, you indicated that AreaCode is an option group, which means that
you're only going to get a selection number (1, 2, 3), rather than an area
code (416, 647, 905). You can use Choose function to translate:

If DCount("*", "tblResume", "[Number] = '" & _
Choose(AreaCode + 1, "416", "647", "905") & _
txtbxINPUT_NUMBER & "'") > 0 Then
Duplicate = True
Else
Duplicate = False
End If


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Rod said:
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
 
G

Guest

Al,

I did everything yo said and it was not working. I check the table and it
was marked as TRUE. I opened the form again and it was working! I think it
must have been the removing and reinstalling of DUPL because everything else
was already as you would expect it to be.

THANKS MUCH FOR YOUR SUPPORT!

Al Camp said:
Rod,
Well, there has to be a problem with the Dupl field....
Is it included in the query behind the form?
Is it bound to the Dupl field... in the ControlSource for the Dupl field
on the form do you have Dupl (no quotes, and not =[Dupl], or anything
else... just Dupl )?
To be sure, when you use the ControlSource property dropdown to select a
field to bind it to... is Dupl on the list?

If you don't find the problem with Dupl, I would think Douglas's code
will not work either.

Also, if you still can't find the problem, remove Dupl from the form and
reinstall it right back. That will set all Dupl properties back to
default... formatting, validation, etc...etc...

hth
Al Camp

Rod said:
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

Debugger is pointing to "DUPL = True".
DLookup appears to be working fine.
AREA_CODE and INPUT_NUMBER are both text fields
DUPL is a boolean of format True/False
I have not tried Douglas's solution yet. I got started with yours and
wanted to give it another swing.

Thanks

Al Camp said:
Rod,
I built a table with 2 number fields... Number1 and Number2. I
populated
the table with
Number1 Number2
1 1
2 2
3 3 etc... etc...

On a form I place two unbound fields named N1 and N2 so I could enter
2
numbers and see if my table contained an entry that contained both
numbers.
I then added an unbound text control with this RecordSource... (just
for
now ditch the Comments= part of the code)
=IIf(IsNull(DLookUp("[Number1]","tblNumbers","[Number1]=[Forms]![frmNumbers]![N1]
And [Number2]=[Forms]![frmNumbers]![N2]")),"Does Not Exist","Does Exist")

If I entered 1 and 1 I got "Does Exist".
If I entered 1 and 9 I got "Does Not Exist"
So... I have to say... the IIF logic part of the code is OK, and you have
some other problem.

*What line in your code did the Debug point to?*
*Can you do ANY OTHER Dlookup at all?*
*Are both AreaCode and InputNumber Number fields?*
*Is Dupl a Boolean type?*
and
*Have you tried Douglas's solution?*

Hang in there...
Al Camp

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


:

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
 
A

Al Camp

Rod,
Good deal!
You may have set something in the Dupl properties that was interfering
with the True/False.
Al Camp
Rod said:
Al,

I did everything yo said and it was not working. I check the table and it
was marked as TRUE. I opened the form again and it was working! I think
it
must have been the removing and reinstalling of DUPL because everything
else
was already as you would expect it to be.

THANKS MUCH FOR YOUR SUPPORT!

Al Camp said:
Rod,
Well, there has to be a problem with the Dupl field....
Is it included in the query behind the form?
Is it bound to the Dupl field... in the ControlSource for the Dupl
field
on the form do you have Dupl (no quotes, and not =[Dupl], or anything
else... just Dupl )?
To be sure, when you use the ControlSource property dropdown to select
a
field to bind it to... is Dupl on the list?

If you don't find the problem with Dupl, I would think Douglas's code
will not work either.

Also, if you still can't find the problem, remove Dupl from the form
and
reinstall it right back. That will set all Dupl properties back to
default... formatting, validation, etc...etc...

hth
Al Camp

Rod said:
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

Debugger is pointing to "DUPL = True".
DLookup appears to be working fine.
AREA_CODE and INPUT_NUMBER are both text fields
DUPL is a boolean of format True/False
I have not tried Douglas's solution yet. I got started with yours and
wanted to give it another swing.

Thanks

:

Rod,
I built a table with 2 number fields... Number1 and Number2. I
populated
the table with
Number1 Number2
1 1
2 2
3 3 etc... etc...

On a form I place two unbound fields named N1 and N2 so I could
enter
2
numbers and see if my table contained an entry that contained both
numbers.
I then added an unbound text control with this RecordSource...
(just
for
now ditch the Comments= part of the code)
=IIf(IsNull(DLookUp("[Number1]","tblNumbers","[Number1]=[Forms]![frmNumbers]![N1]
And [Number2]=[Forms]![frmNumbers]![N2]")),"Does Not Exist","Does
Exist")

If I entered 1 and 1 I got "Does Exist".
If I entered 1 and 9 I got "Does Not Exist"
So... I have to say... the IIF logic part of the code is OK, and you
have
some other problem.

*What line in your code did the Debug point to?*
*Can you do ANY OTHER Dlookup at all?*
*Are both AreaCode and InputNumber Number fields?*
*Is Dupl a Boolean type?*
and
*Have you tried Douglas's solution?*

Hang in there...
Al Camp

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


:

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
 

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

Top