Working in Access 2003.
I have managed to duplicate a record using a button on a form with code: Private Sub Command16_Click ()
On Error GoTo Err_Command16_C lick
DoCmd.DoMenuIte m acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuIte m acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuIte m acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
Exit_Command16_ Click:
Exit Sub
Err_Command16_C lick:
MsgBox Err.Description
Resume Exit_Command16_ Click
End Sub
But this just creates a duplicate of the fields on the form, which is fine, but i would also like to +1 to one of the fields on the new record.
Is this possible? If so how would i do it.
Also.....
If this is possible,
would it also be possible to have a drop down menu in which to select say (n)1-9 and that is how many duplicates it will make with field +(n).
so the first duplicate will be the same but a field will have +1, and the next +2, etc.
for the selected number of fields
Mar 16 '07
12 2141
ive tried that, but i get a "type mismatch" error now
Ok, well i got it all sorted now. using this code: Private Sub Command16_Click ()
On Error GoTo Err_Command16_C lick
Dim i As Integer, cnt As Integer, varBk As String
varBk = Me.Bookmark
cnt = Me!Combo17
For i = 0 To cnt - 1
DoCmd.DoMenuIte m acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuIte m acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuIte m acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
Me!Text22 = Me!Text22 + 1
Next
Exit_Command16_ Click:
Me.Bookmark = varBk
Exit Sub
Err_Command16_C lick:
MsgBox Err.Description
Resume Exit_Command16_ Click
End Sub
But......
Is it also possible to stop this solution making a duplicate duplicate.
What i mean is; this solution creates a duplicate of fields x, y, z and w+1.
So this is not creating exact duplicates, as w value has changed for each record.
Now if you hit this button, or run this, twice, there will be REAL duplicates, as there will be 2 copies of x ,y, z and w+1.
So..
Is it possible to add code that will replace the old duplicate.
Also because z is a variable and i may want this changed on the duplicates, if they already exist i can't just block the new duplicate being sent.
Denburt 1,356
Recognized Expert Top Contributor
You can use something like the following to prevent duplication of data or change it up to suite your needs.
rs= me.recordsetclo ne
if rs.findfirst (PutWhereCondit ionHere) Then
rs.close
set rs = nothing
exit sub
end if
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Bill Kellaway |
last post by:
Hi there - this should be fairly simple for someone. Basically I
can't figure out how to pass the parameters from ASP to a Stored
Procedure on SQL.
Here's my code:
I just need to help in learning how to pass these varibables from ASP
to the SP.
|
by: Rob Knowles |
last post by:
I have created a script that runs once a week and copies data from one
table (phpbb_users is the actual table name) in a database called
users
I have a table called users. There are two tables in this database.
The table names are:
phpbb_users
phpbb_users_backup
|
by: Mark |
last post by:
When my form goes to a new record, I have a procedure that copies the last
record added to the form's underlying table into the form. The intent is that a
series of new records may have the same data in many of the fields so I paste in
the same values of the previous record and then edit what needs edited in the
new record saving much retyping of the same data. Doing this however creates the
definite possibility of creating a duplicate...
|
by: Steph |
last post by:
Hi.
I'm very new to MS Access and have been presented with an Access database
of contacts by my employer.
I am trying to redesign the main form of the database so that a button
entitled 'search' may be clicked on by the user and the user can then
search all records by postcode. I want to do this to prevent duplicate
data entry.
|
by: accesstribe |
last post by:
Hello, I have DB located on network, and network cable was cut off
accidently few days ago... now its fixed, but I can't add new records
to the DB with forms...
The error I get is this (when trying to add new record):
"The changes you requested to the table were not successful because
they would create duplicate values in the index primary key or
relationship. Change the data in the field or fields that contation
duplicate data, remove...
| |
by: DP |
last post by:
hi,
i've got a price of code, which checks to see if a film is on rent, or
available. but how can i actualyl make the cancel button do somthing?
because, the cursor gets stuck on the filmID field. this is wat i've got so
far;
Private Sub FilmID_BeforeUpdate(Cancel As Integer)
If DCount("*", "tblFilmRental", "FilmID=" & Me!) > 0 Then
Cancel = True
|
by: Jay |
last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send
text messages to many, many employees via system.timer at a 5 second
interval. Basically, I look in a SQL table (queue) to determine who needs
to receive the text message then send the message to the address. Only
problem is, the employee may receive up to 4 of the same messages because
each thread gets the recors then sends the message. I need somehow to
prevent...
|
by: Tom_F |
last post by:
To comp.databases.ms-access --
I just discovered, to my more than mild dismay, that some tables in my
Microsoft Access 2003 database have duplicate numbers in the
"AutoNumber" field. (Field Size is set to "Long Integer", and New
Values is set to "Increment".) I know that an old version of the Jet
database engine can cause this problem, but my version of msjet40.dll
is 4.0.8618.0, which is supposedly bug-free in this respect. I am...
|
by: theaybaras |
last post by:
Hi All...
I've read both of the requery discussions I could find...
Refresh ComboBox After Adding New Values via a Seperate Form
and
refresh a form
but am not quite able to get this to apply to my database.
I have a table/form called Author_Info where information about authors is entered. The fields of interest here are:
Author_Last
Author_First
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |