Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

duplicate entries in table

Status
Not open for further replies.

scollins

MIS
Nov 30, 2001
5
US
I would like to be able to submit data from my form into the table but if it is already in the table then create a new entry. So at times, the advisor will be the same along with other fields but I want each entry to be its own and not overwrite other entries. Here is some of the code:

If choice = vbOK Then

Set dbs = CurrentDb()
str = "SELECT * FROM [Production Table] "
str = str & "WHERE [Advisor]=" & "'" & Me![Advisor] & "'" & ";"
Set rst = dbs.OpenRecordset(str)
If IsNull(Me![Advisor]) Then
MsgBox "You must enter an Advisor", vbExclamation
Me!Advisor.SetFocus
Else
rst.AddNew
rst![Advisor] = Me!Advisor
rst.Update
Set rst1 = dbs.OpenRecordset(str)
If IsNull(Me![Company]) Then
MsgBox "You must enter a Company", vbExclamation
Me!Company.SetFocus
Exit Sub
Else
rst1.Edit
rst1![Company] = Me![Company]
rst1.Update
End If
If IsNull(Me![Product Type]) Then
MsgBox "You must enter a Product Type", vbExclamation
Me!Client.SetFocus
Exit Sub
Else
rst1.Edit
rst1![Product Type] = Me![Product Type]
rst1.Update
End If
If IsNull(Me![Face Amount]) Then
MsgBox "You must enter a Face Amount", vbExclamation
Me![Face Amount].SetFocus
Exit Sub
Else
rst1.Edit
rst1![Face Amount] = Me![Face Amount]
rst1.Update
End If
If IsNull(Me![Premium]) Then
MsgBox "You must enter a Premium", vbExclamation
Me!Premium.SetFocus
Exit Sub
Else
rst1.Edit
rst1![Premium] = Me![Premium]
rst1.Update
End If
If IsNull(Me![Mode]) Then
MsgBox "You must enter a Mode", vbExclamation
Me!Mode.SetFocus
Exit Sub
Else
rst1.Edit
rst1![Mode] = Me![Mode]
rst1.Update
End If
If IsNull(Me![Date Entered]) Then
MsgBox "You must enter a Date Entered", vbExclamation
Me![Date Entered].SetFocus
Exit Sub
Else
rst1.Edit
rst1![Date Entered] = Me![Date Entered]
rst1.Update
End If
If IsNull(Me![UW Status]) Then
MsgBox "You must enter an Underwriting Status", vbExclamation
Me![UW Status].SetFocus
Exit Sub
Else
rst1.Edit
rst1![UW Status] = Me![UW Status]
rst1.Update
End If
rst1.Edit
rst1![Date Issued] = Me![Date Issued]
rst1.Update
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top