Duplicate entries

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

Guest

How do you check to see if there is already a duplicate entry with vba code?
Lets just say theres a table called Name with:
Field Name Data Type
First Name Text
Last Name Text
You enter in Micheal into FirstNameTextBox and Moore into LastNameTextBox
but this entry already entered into our table because the vba code has
checked the Name table out and gives a message box stating that.
 
You can use a dlookup in the before update of the form

if not isnull(dlookup("PK","YourTable","[First Name] ='"& Me![FirstName] &
"' and [LastName] = '" & Me![LastName] & "'")) then
msgbox("Already exisits")
end if
 
Im getting an error that says

Run-time error '2001':
You cancelled the previous operation.


schasteen said:
You can use a dlookup in the before update of the form

if not isnull(dlookup("PK","YourTable","[First Name] ='"& Me![FirstName] &
"' and [LastName] = '" & Me![LastName] & "'")) then
msgbox("Already exisits")
end if


tanhus said:
How do you check to see if there is already a duplicate entry with vba code?
Lets just say theres a table called Name with:
Field Name Data Type
First Name Text
Last Name Text
You enter in Micheal into FirstNameTextBox and Moore into LastNameTextBox
but this entry already entered into our table because the vba code has
checked the Name table out and gives a message box stating that.
 
Can you please post the code you have.

tanhus said:
Im getting an error that says

Run-time error '2001':
You cancelled the previous operation.


schasteen said:
You can use a dlookup in the before update of the form

if not isnull(dlookup("PK","YourTable","[First Name] ='"& Me![FirstName] &
"' and [LastName] = '" & Me![LastName] & "'")) then
msgbox("Already exisits")
end if


tanhus said:
How do you check to see if there is already a duplicate entry with vba code?
Lets just say theres a table called Name with:
Field Name Data Type
First Name Text
Last Name Text
You enter in Micheal into FirstNameTextBox and Moore into LastNameTextBox
but this entry already entered into our table because the vba code has
checked the Name table out and gives a message box stating that.
 
If Not IsNull(DLookup("PK", "TimeCardApproval", "[Team Member ID] ='" &
TeamMemberCombo.Value & "' and [Week Ending] = '" & DateText.Value & "'"))
Then
MsgBox ("Already exisits")
End If

TimeCardApproval is the table
Team Member ID is the field name in the table
TeamMemberCombo.Value is the textbox in the form in which im checking to see
if its in the table
Week Ending is the field name in the table
DateText.Value us the textbox in the form in which im checkign to see if its
in the table

schasteen said:
Can you please post the code you have.

tanhus said:
Im getting an error that says

Run-time error '2001':
You cancelled the previous operation.


schasteen said:
You can use a dlookup in the before update of the form

if not isnull(dlookup("PK","YourTable","[First Name] ='"& Me![FirstName] &
"' and [LastName] = '" & Me![LastName] & "'")) then
msgbox("Already exisits")
end if


:

How do you check to see if there is already a duplicate entry with vba code?
Lets just say theres a table called Name with:
Field Name Data Type
First Name Text
Last Name Text
You enter in Micheal into FirstNameTextBox and Moore into LastNameTextBox
but this entry already entered into our table because the vba code has
checked the Name table out and gives a message box stating that.
 
You need to change the PK with a field from your table, perferably the
primary key of the table. If TeamMemberID is a number you need to remove the
' before and after. If DateText is a date you may need to add # before and
after

If Not IsNull(DLookup("PK", "TimeCardApproval", "[Team Member ID] =" &
Me.TeamMemberCombo.Value & " and [Week Ending] = #" & Me.DateText.Value &
"#"))

tanhus said:
If Not IsNull(DLookup("PK", "TimeCardApproval", "[Team Member ID] ='" &
TeamMemberCombo.Value & "' and [Week Ending] = '" & DateText.Value & "'"))
Then
MsgBox ("Already exisits")
End If

TimeCardApproval is the table
Team Member ID is the field name in the table
TeamMemberCombo.Value is the textbox in the form in which im checking to see
if its in the table
Week Ending is the field name in the table
DateText.Value us the textbox in the form in which im checkign to see if its
in the table

schasteen said:
Can you please post the code you have.

tanhus said:
Im getting an error that says

Run-time error '2001':
You cancelled the previous operation.


:

You can use a dlookup in the before update of the form

if not isnull(dlookup("PK","YourTable","[First Name] ='"& Me![FirstName] &
"' and [LastName] = '" & Me![LastName] & "'")) then
msgbox("Already exisits")
end if


:

How do you check to see if there is already a duplicate entry with vba code?
Lets just say theres a table called Name with:
Field Name Data Type
First Name Text
Last Name Text
You enter in Micheal into FirstNameTextBox and Moore into LastNameTextBox
but this entry already entered into our table because the vba code has
checked the Name table out and gives a message box stating that.
 
thanks that helped

schasteen said:
You need to change the PK with a field from your table, perferably the
primary key of the table. If TeamMemberID is a number you need to remove the
' before and after. If DateText is a date you may need to add # before and
after

If Not IsNull(DLookup("PK", "TimeCardApproval", "[Team Member ID] =" &
Me.TeamMemberCombo.Value & " and [Week Ending] = #" & Me.DateText.Value &
"#"))

tanhus said:
If Not IsNull(DLookup("PK", "TimeCardApproval", "[Team Member ID] ='" &
TeamMemberCombo.Value & "' and [Week Ending] = '" & DateText.Value & "'"))
Then
MsgBox ("Already exisits")
End If

TimeCardApproval is the table
Team Member ID is the field name in the table
TeamMemberCombo.Value is the textbox in the form in which im checking to see
if its in the table
Week Ending is the field name in the table
DateText.Value us the textbox in the form in which im checkign to see if its
in the table

schasteen said:
Can you please post the code you have.

:

Im getting an error that says

Run-time error '2001':
You cancelled the previous operation.


:

You can use a dlookup in the before update of the form

if not isnull(dlookup("PK","YourTable","[First Name] ='"& Me![FirstName] &
"' and [LastName] = '" & Me![LastName] & "'")) then
msgbox("Already exisits")
end if


:

How do you check to see if there is already a duplicate entry with vba code?
Lets just say theres a table called Name with:
Field Name Data Type
First Name Text
Last Name Text
You enter in Micheal into FirstNameTextBox and Moore into LastNameTextBox
but this entry already entered into our table because the vba code has
checked the Name table out and gives a message box stating that.
 
No problem

tanhus said:
thanks that helped

schasteen said:
You need to change the PK with a field from your table, perferably the
primary key of the table. If TeamMemberID is a number you need to remove the
' before and after. If DateText is a date you may need to add # before and
after

If Not IsNull(DLookup("PK", "TimeCardApproval", "[Team Member ID] =" &
Me.TeamMemberCombo.Value & " and [Week Ending] = #" & Me.DateText.Value &
"#"))

tanhus said:
If Not IsNull(DLookup("PK", "TimeCardApproval", "[Team Member ID] ='" &
TeamMemberCombo.Value & "' and [Week Ending] = '" & DateText.Value & "'"))
Then
MsgBox ("Already exisits")
End If

TimeCardApproval is the table
Team Member ID is the field name in the table
TeamMemberCombo.Value is the textbox in the form in which im checking to see
if its in the table
Week Ending is the field name in the table
DateText.Value us the textbox in the form in which im checkign to see if its
in the table

:

Can you please post the code you have.

:

Im getting an error that says

Run-time error '2001':
You cancelled the previous operation.


:

You can use a dlookup in the before update of the form

if not isnull(dlookup("PK","YourTable","[First Name] ='"& Me![FirstName] &
"' and [LastName] = '" & Me![LastName] & "'")) then
msgbox("Already exisits")
end if


:

How do you check to see if there is already a duplicate entry with vba code?
Lets just say theres a table called Name with:
Field Name Data Type
First Name Text
Last Name Text
You enter in Micheal into FirstNameTextBox and Moore into LastNameTextBox
but this entry already entered into our table because the vba code has
checked the Name table out and gives a message box stating that.
 

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