add new record-if duplicate edit existing record in table

add new record-if duplicate edit existing record in table

Post by SmF5S » Fri, 15 Apr 2005 05:09:21


I have been trying to scan a text field(serial) into a table(serials) where
no duplicates are allowed by design. However, serial is scanned into form
and added as new record, but if it exists in table an error occurs. Here is
code i have so far,
would like help with (dlookup) or (if then else )statement.
Form Main-Serial Inventory, subform Main-Sub-Serials

FORM- MAIN-SUB-SERIALS
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "Form_Main-Sub-Serials"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Compare Database
Private Sub Serial_Enter()
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer7
End Sub

Private Sub Serial_Exit(Cancel As Integer)
On Error GoTo Err_Nextrec_Click

DoCmd.GoToRecord , , acNewRec
Exit_Nextrec_Click:
Exit Sub
Err_Nextrec_Click:
MsgBox Err.Description
Resume Exit_Nextrec_Click
End Sub
Private Sub Command9_Click()
On Error GoTo Err_Command9_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Exit_Command9_Click:
Exit Sub
Err_Command9_Click:
MsgBox Err.Description
Resume Exit_Command9_Click
End Sub
Private Sub Command11_Click()
On Error GoTo Err_Command11_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
Exit_Command11_Click:
Exit Sub
Err_Command11_Click:
MsgBox Err.Description
Resume Exit_Command11_Click
End Sub
Private Sub Command12_Click()
On Error GoTo Err_Command12_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
Exit_Command12_Click:
Exit Sub
Err_Command12_Click:
MsgBox Err.Description
Resume Exit_Command12_Click
End Sub

Thank you in advance, if anyone can help on this!!!!
 
 
 

1. Access linked table - can add new records but can't update existing records

2. Select Record in query, save as New Record then edit New Record

Hi,
I have a Select Query with a Split Form attached to it. Access 2007.

I print out single page Lab Test Certificates that are sent out to Customers.

This is done through a Report also attached to the same Query.

When you click on a record visible in the bottom of the Split Form, it shows
in the fields (test boxes) in the upper portion of the form. The report is
created using this active record that is showing in the form.

Sometimes the same Certificate (record) is used again and only certain
fields need changing to create a new one. I would like to keep the old
record with it's original ID number.

Using a Command Button. Would it be possible to copy the selected query
record in the form, then paste it into the next (new) blank record so it may
be utilized as a new certificate for printing?

This is my very first Database. I've always used Excel, so I have some
experience with V.B. but still a novice. I see you cannot record macros in
Access, and I did not see what I wanted to do in the macro builder.

Thank you for your time, and thanx in advance if anyone has suggestions for
this beginner.
Amy

3. Add new record from a form to a table, then record new ID

4. Create new table from existing table (adding records)

5. Sharepoint linked table - can add records but can't update existing records

6. Add New Record / Make Existing Records Read Only

7. Prevent the user from adding a new record while still allowing him to modify existing records

8. Add New Record between two existing records

9. Using combo box to add new records and search for existing records

10. open a record if it exists; otherwise add new record

11. Add new record to a log when existing records are modified?

12. Adding new records and updating existing records from different ta

13. PLS help i need to Add new record to an existing records

14. Opening Form To Add New Records + View Existing Records

15. Create New Records in a Table by Copying Existing Records