Question

Dang error: The changes you requested were not successful because they...

Get this error in Access telling me changes would duplicate a record or screw with PK, indexes or relationships. So I build a one table, one field database with one form and a command button to insert 50 records into a table. The only field is not a PK but is indexed and no dupes allowed. Here's the code:

Private Sub cmdEnterTickets_Click()

Dim strSQL As StringDim intX As LongDim Book_No As String

If Nz(Me.txtFirstBookNumber, "") = "" Then

MsgBox "Please enter the Starting Book Number", 48, "Enter Number"

Me.txtFirstBookNumber.SetFocus

Exit Sub

End If

If Nz(Me.txtLastBookNumber, "") = "" Then 'no last number entered

'Insert 50 records in table, beginning with the number in Me.txtFirstBookNumber'AND update the book_no field for all 50 new records with the number in Me.txtFirstBookNumber'e.g. number in text box is 700001, insert records with tickets numbered'from 700001 to 700050 and all 50 new records have book_no as 700001'This code works:

For intX = Me.txtFirstBookNumber To Me.txtFirstBookNumber + 49

strSQL = "INSERT INTO tblTickets (ticket_no) VALUES (" & intX & ")"

CurrentDb.Execute strSQL, dbFailOnError

Next intX

End IfEnd Sub

Each new record has a unique number, so how can Access throw this error?

All Answers

Start or search

Create a new discussion

If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.

Post type

Subject title

Topic Tags

Select up to 3 tags (1 tag required)

Cloud

Piracy

Security

Apple

Microsoft

IT Employment

Google

Open Source

Mobility

Social Enterprise

Community

Smartphones

Operating Systems

Windows

Mac

Malware

Tablets

Networking

Browser

Hardware

Software

Web Developerment

Linux

Off Topic

Message Body

Track this discussion and email me when there are updates

Please note: Do not post advertisements, offensive material, profanity, or personal attacks. Please remember to be considerate of other members. If you're new to the TechRepublic Forums, please read our TechRepublic Forums FAQ. All submitted content is subject to our Terms Of Use.