I am having an issue with one person having trouble getting an error when trying to duplicate a record.
The subform is set up with a button to duplicate a record. This allows most of the data that stays the same to be copied to a new records and then minor changes can be made to update the record for the new month. Since there are memo fields, in these records, this saves a lot of retyping. One person who is using the database gets the following error when clicking on the duplicate record button.
The command or action 'Copy' isn't available now.
It makes a new blank record but won't copy over the information. You can go to the record and copy each field individually and paste it into the new record, but this is not very practical.
I have not been able to duplicate the error and no one else using the database is having this happen.
I am working on a database used in recording device characteristics/test information. The main table of information has dozens of columns for test/part detailed information. When inputing the data for each specific test, many of the info. details are repeated when testing say 20 devices of the same part all at once. Rather than retype every piece of detailed information in every field, everytime, is there an easier way? Does anyone know of a way to make specific fields copy/paste the previous record's information in the fields automatically when a new record is created? Please, if anyone could help or has ANY ideas, let me know...
When i try to execute the code via a comand button, i get an error and the duplicate record operation does not occur. one thing i noticed is that i have a lot of lookup fields (i.e. FK's to lookup tables one-to-many relationships) in underlying table being populated by the form. i've created combo boxes on the form to populate the FK's in the underlying table. the error that occurs when trying to use the above code produces a "paste errors" table and in that paste errors table instead of the bound column values from the combo boxes (i.e. PK values from the lookup tables) it shows the display values from the combo boxes. i'm not sure if this has do with anything, but i couldn't figure out why it was doing this.
does anyone have any ideas how i could get this duplicate record procedure to work?
Having a problem when saving a record that has been edited and contains a duplicate field. Here is what I'm doing.
I have an existing record that is being viewed by the user. I have an edit button on the form that is displaying the record. When the user clicks the edit button I do the following
'User clicked on edit customer record
Private Sub CustEditRec_Click()
'Store current customer key in string so we can cross
'Set customer record test string so we can determine
'what the user is doing
CustomerRecStat = "edit"
' Go unlock the customer data fields for editing
UnlockCustomerFields
TxtCompanyName.SetFocus
'Go Unlock the customer editing buttons
UnLockCustomerAddButtons
'Lock the add, delete, edit buttons
CustAddRec.Enabled = False
CustEditRec.Enabled = False
CustDelRec.Enabled = False
'Go Disable the customer navagation buttons
DisableCustomerNavigation
txtCustomerKey.Visible = True
txtCustomerKey.Locked = False
txtCustomerKey.Enabled = True
'Set focus on the customer key
txtCustomerKey.SetFocus
'disable & hide the customer key combobox
cmboCustomerKey.Locked = True
cmboCustomerKey.Enabled = False
cmboCustomerKey.Visible = False
Exit_CustEditRec_Click:
Exit Sub
Err_CustEditRec_Click:
MsgBox Err.Description
Resume Exit_CustEditRec_Click
End Sub
The field which duplicate entries are not allowed in the table is txtCustomerKey. Now remember we are just editing a record NOT ADDING A NEW ONE.
When the user finished making the changes to the record we use the same procedure to save the changes as we when the user is adding a new record...here it is.
'User clicked save customer record
Private Sub CustSaveRec_Click()
On Error GoTo Err_CustSaveRec_Click
SaveCustomerRecord:
'Update the table data fields with the data contained on the form
'*** IF WE GOT THIS FAR WITH OUT ERRORS WE SAVED THE RECORD
'*** GO AHEAD & DISABLE THE FORMS VARIOUS FIELDS
'*** & BUTTONS ONCE AGAIN AS WE ARE JUST BACK TO VIEWING
'*** THE CUSTOMERS DATABASE
'Enable and unlock the customer key field
txtCustomerKey.Visible = True
txtCustomerKey.Locked = False
txtCustomerKey.Enabled = True
'Hide & disable the customer keycombo box
cmboCustomerKey.Locked = True
cmboCustomerKey.Enabled = False
cmboCustomerKey.Visible = False
'Set focus on the customer key field
txtCustomerKey.SetFocus
'Lock the customer fields
LockCustomerFields
'Enable the navigation buttons
EnableCustomerNavigation
'Lock the customer adding buttons
LockCustomerAddButtons
'Clear the record testing status
CustomerRecStat = ""
txtCustomerKey_AfterUpdate
Exit_CustSaveRec_Click:
Exit Sub
Err_CustSaveRec_Click:
'If the error generated was by a duplicate value.
'This can only be caused by the customer key as this
'is the only field which does not allow duplicate values.
'so warn the user of this duplicate value error and set
'the focus on the customer key field
If Err.Number = 3022 Then
'if user is editing a record
If CustomerRecStat = "edit" Then
'And the entered customer key has not changed
If Me.txtCustomerKey = EditCustKey Then
'Return to saving the record as the key is
'not really a duplicate
GoTo SaveCustomerRecord
End If
End If
Select Case MsgBox("This Customer ID was already located in the database. Click OK to enter a new Customer ID or Cancel to stop adding this record?", vbExclamation + vbOKCancel + vbDefaultButton1, "Duplicate Customer ID")
Case vbOK
Me.txtCustomerKey.SetFocus
Resume Exit_CustSaveRec_Click
Case vbCancel
'Go simulate undo record click
CustUndoRec_Click
Resume Exit_CustSaveRec_Click
End Select
End If
MsgBox Err.Description
Resume Exit_CustSaveRec_Click
End Sub
The problem is when the user is editing a record. The database assumes the txtCustomerKey is a duplicate in the table. However we are not adding a new record so the duplicate error is false. Its just that the txtCustomerKey is the same as the record being edited. Its not DUPLICATED its the SAME.....
Any help anyone? Sorry for the long post but I'm a strong believer in the more information the better when trying to solve a problem....
I need to be able to produce an error on a form where the user attempts to create a new user that already exists. The error needs to be produced when the save button is clicked.
See below for the existing code on my save button which exists in form, 'frmAddEditUser':
Private Sub cmdSave_Click() If IsNull(cboManagerID) = True Then MsgBox "Please select a manager", vbExclamation, "Details Missing!" Me.cboManagerID.Requery
[Code] ....
Currently, if I attempt to create a user with the same Payroll ID as an existing user, my 'User details saved' message box is displayed and to the user it looks like a new record has saved successfully which isn't the case.
I need a message box to appear displaying something like "Payroll ID n already exists" where n is the 'PayrollID' of the duplicate record. (Is it possible to combine a value from a certain control and ones own custom text?)
Note: PayrollID is a combination of letters and numbers, i.e. two letters, followed by 5 numbers, e.g. JD12345.
For reference, the table/field and and control are called, '[tblUser].[PayrollID]' and 'txtPayrollID' (on 'frmAddEditUser') respectively; it is from this field and control that I want the error to be produced if the user is entering the same values which are existing in 'tblUser'.
error message I am getting when I click on my Duplicate Record button (created through the wizard).
I have two combo boxes on the main form that populates data when the user makes a selection from the combo box. First combo box populates project data and the second combo box populates equipment data. The form is working well with the two combo boxes populating the data into the main table.
Now I would like to add a duplicate record button to copy a record and paste the data as a new record. So, I added a duplicate record button using the wizard and I am receiving the following AfterUpdate error.
Run-time error 3020: Update or CancelUpdate without AddNew or Edit.
This is the code I am using to copy and paste a duplicate record:
Private Sub InputForm_DupRec_Button_Click() On Error GoTo Err_InputForm_DupRec_Click DoCmd.RunCommand acCmdSelectRecord DoCmd.RunCommand acCmdSaveRecord DoCmd.RunCommand acCmdCopy DoCmd.RunCommand acCmdPasteAppend Exit_InputForm_DupRec_Click: Exit Sub Err_InputForm_DupRec_Click: MsgBox Err.Description Resume Exit_InputForm_DupRec_Click
It seems to be duplicating the data from the first combo box, but not the second one where it errors out.
I am having error message when I tried to make my mdb file to mde. The error message is "MS Access unable to create an MDE database". Reading through the help message it says that this problem always occurrs in trying to compile large db into MDE. So what can I do to solve this problem. Also what is MS access memory capacity. thanks
I am attempting to set up a saved import procedure in an Access database that will be run programmatically using docmd.RunSavedImportExport. The source document is an Excel file.My goal is to trap any import errors caused by inconsistencies in the source data. I'd also like to provide the user with some small amount of feedback on what is causing these errors.
My initial thought was to make use of the "File_ImportErrors" table that is generated following an unsuccessful import. *Not once* has this import procedure consistently generated an error table - sometimes the table is created, sometimes it isn't.
I have tried changing the file format of the import file to comma- and tab-delimited files, respectively. Both of these formats do consistently generate an error table, however none of the error values in the table are accurate - it reports a slew of type conversion errors for fields that are completely consistent and unproblematic, whilst completely overlooking conspicuous errors from text strings in date fields.
I have tried the same import, both procedurally and manually, using all available Excel and text-delimited formats, with the same respective results.I notice that nearly every thread on AWF pertaining to error tables discusses how to delete them, rather than make effective use of them. I suspect this is perhaps why?
I have a subform (continuous) which shows a summary of all clients basic data in a list. Clicking a client requerys and refreshes some other subforms so the accompanying data for that client is shown. Whenever I double click a record, the "main" window for that "object" opens. So say I double click on client A1 in the summary list, a form opens where I can view all the clients data and change it if necessary. That same form is also used to add clients to the database.
Whenever I change or add a clients data and close the form, the following code is executed:
Private Sub Form_Close() On Error GoTo ClientsAdd_Err
ClientsAdd_Err: MsgBox Error$ Resume ClientsAdd_Exit End Sub
Which makes the new client appear in the summary list or makes the changed data of an existing client appear in the summary list. That's what I want it to do of course.
But whenever that is done, the cursor jumps back to the first record (client 1) in the summary list. What I would like to have happen is:
- when a new client has been added, keep the cursor on that client in the summary list after the form closes and the list is updated.
- when a record of an already existing client is changed and the form closes, keep the cursor on that client in the list also.
DoCmd.GoToRecord acForm, "ClientsViewSummarySubForm", acLastgives "The object ClientsViewSummarySubForm isn't open. As does the same line of code but then using the name "ClientsViewSummary". The form itself is called that way. The subform object itself goes by: "ClientsViewSummarySubForm".
I've tried some variations but all without succes. Which line of code is the correct one to use for a subform on a parentform instead of "just" a normal, open form?
I have created a button with Macro located on form in record. It does what I want except I want it to display only last record. Currently it is displays first record and I have to scroll. See attached photo of what I have. Access 2010
In the above field i had set Sno is PRIMARY KEY. The problem is after entering all field, then only it will show the duplicate Sno error. What I want is, if Sno is duplicate, when i type SNo , successively i have to get the SNo is duplicate.
hi, i have a form, which when opened, gives me a blank record. which is what i asked it to do in the OnOpen property. however, i also need a msg box to popup - but after the form has been opened. i tried placing both pieces of 'code' into the OnOpen property, however, the popup displays first, then the form opens.
so currently i have:
Private Sub Form_Load() Select Case MsgBox("Please select the Registration Number from the drop down menu or type it in", vbOKOnly, "Select Registration Number")
End Select End Sub -------------------------------------------------------------------------- Private Sub Form_Open(Cancel As Integer) DoCmd.GoToRecord , , acNewRec
End Sub --------------------------------------------------------------------------
but it does the same thing. so, is there a way to make the msg box appear after the form opens with a blank record? thank you in advance :D
Hi I have a very simple table, with say 5 fields (all text). There is only 1 table. The first field is name, and I want to enforce its uniqness across all other table.name values. I am completely new to Access database and am not sure how to do this. Any help would be greatly appreciated.
the below scrip was taken from another forum member.
i have put this in the Forms / error VBA
but i still a little lost
i have set 3 fields to be indexed not to allow duplicate information (Forename, Surename, DOB)
i was then advised to error trap so it would highlight that i have enterd a duplicate record on typing in the DOB (As that as third feild to be entered)
so i then used the below script, however this doesnt highlight that it is a duplicate it just doesnt let me go on to the next record, the only time the error message is highlighted is when i go into design mode.
anyideas on where to go from here.
Private Sub Form_Error(DataErr As Integer, Response As Integer) If DataErr = 3022 Then Response = acDataErrContinue MsgBox "Tis MerID alredy exist!" Exit Sub End If If DataErr = 2169 Then Response = acDataErrContinue MsgBox "Tis record will not be saved!" Exit Sub End If
I have a MS Access 2000 database with 136 data tables in it. What I would like to do is execute a piece of VBA code which will list for me in another table, (for example: Field1: TABLE NAME Field2: FIELD NAME 1 Field2: FIELD NAME2 etc), starting left to right, how many fields would have to be combined in each table to represent a unique record.
For instance:
TYPE ID TEXT 1 1 "Cats" 1 2 "Dogs" 2 1 "Rabbits"
In this example a combination of the fields TYPE and ID give a unique record.
Hi, I have a rather large database that was built in Access '97 and recently converted to 2003. I have a couple problems now. I get an error message about not being able to update the form because it would create a duplicate value in the primary key, index, or relationship. (Error 3022) I didn't build this particular database so I'm not totally sure why somethings are done the way they are. I've spent a long time going through everything to try to understand the relationships and I've asked lots of people at work to look at it, but no one seems to understand why it's doing what it's doing. The Access Help information has helped me understand some things better, but not this problem. I've gone through every table and removed all primary keys and set all indexes to allow duplicates. Then, when I was looking at the relationships and object dependancies, I think everything looks to be in order. However, when i add info directly to the table instead of using the form, the form is not updated with the new info. the table keeps the information, but isn't communicating with the form and i suspect reverse is true which is where the error is coming from. But how do I detect that for sure and how can I fix it with out starting over? I've gone through and added data to one field in the form at a time to try and narrow down what field is causing the problem, but no matter what i get the same error. Is there a way to find out exactly what field is causing the error? Thanks for any help you can offer!
I created a subforum with an updateable query, and this works. I can view the results of the query, modify them and add new records.
However I shortly realized that once I deleted a record (either by some VBA code, or by SQL) that I could not re-add the same record through the subform.
I've made sure that the record is deleted, so there is no duplication of the key. I've made sure that Index is Duplicates OK, so there is no duplication issues there.
I have a table with one primary key (ClientID) which is an autonumber (cannot be duplicated), and another field which is a number field which is set to a random 6 digits (also cannot be duplicated) whenever a new client record is created.
Now, the main database is on a desktop, and my partner and i are connected to this main database through our laptops whenever we're in the office. For the last 6 months, I had only the ClientID in the form (from the Client Table), and everything would work fine whenever we created a new record in the Form, even if we created a new record at the same time on our personal laptops, the numbers would automatically be increased by one w/ no error.
I just added the other field now, the regular 6 digit random number field, and sometimes (only sometimes) when we both have a different client and start a new record, we get error messages that says we're creating duplicates. When that error message comes up, one of us has to close down the form completely, and reopen and start a new record again. Not sure why this is happening. Here is the error message.
I have a form - see attached image. The first text box is called Job_No. When a number is entered here how can I check that the number doesn't already exist when the user tabs to the next box. Then if it does exist display a custom message to the effect "This already exists" and not the Access default duplicate error message.
I have a form which is based on student records. What I'm trying to get Access to do is to bring up an error message as soon a duplicate student number has been entered. At present I've managed to replace the Access standard error message 3022 with my own by using the following code:
Private Sub Form_Error(DataErr As Integer, Response As Integer) Const conDuplicateKey = 3022 Dim strMsg As String
If DataErr = conDuplicateKey Then Response = acDataErrContinue strMsg = "Duplicated record. Please recheck your data." MsgBox strMsg End If End Sub
However the error message only appears when you try to leave the form (e.g. start a new record). I would like the error message to appear as soon as the user leaves the Student Number text box on the form. Is there anyway to do this?
I have a table with about 3600 keys, numbered from 1 to 3600. When I try to enter a new record, the autonumber starts in the 20's. I get an error message about duplicate keys, and I have to cancel. If I try again the autonumber goes up by one, but it will take hours to do this with approximately 3600 tries to get past the highest exisiting key number. Is there a way to make Access reset this? THis table is linked to a many-to-many table and I can't start over or I will lose all my relationships.
So now, I'm using the code below to prevent duplicate name entry and it is working great - EXCEPT when I enter a first or last name which contains a ' (ie, O'Tool, O'Malley, O'Hern)...anyone got any ideas for me on how to make this not happen?
The error I get is:
Run Time error '3075'
Syntax error (missing operator) in query expression '[Last Name]='O'Hern' And [First Name]='Lori'.
The code i'm using is:
Private Sub Last_Name_AfterUpdate()
'Check for duplicate first and last name using DCount
If DCount("*", "[Constituents]", "[Last Name]= '" & Me![Last Name] & "' And [First Name] = '" & Me![First Name] & "'") > 0 Then Beep MsgBox "This first and last name already exists in the database. Please check that you are not entering a duplicate constituent before continuing.", vbOKOnly, "Duplicate Value" Cancel = True End If