473,786 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem of copying records

Rex
In a table, I have number of records belonging to a particular ID now
if I enter a value in one of the fileds of this table I want it to be
copied in all the records belonging to this particluar ID. for example

ID Name
--------------------------
1 xyz
1
1
1
2
2
2
When I enter "xyz" for any one of the record of ID# 1.. I want all the
other records (with ID# 1) to have the name field as "xyz" so after
this.. the table would look like this

ID Name
--------------------------
1 xyz
1 xyz
1 xyz
1 xyz
2
2
2

I know this is not possible in table itself.. However I presume it
would be possible to do this in a form. But I dont know HOW

cheers
Rex

Oct 5 '06 #1
38 1815
'******** Code Start **********
const cQuote="""" 'Thats two quotes
me!Control.Defa ultValue = cQuote & me!Control.Valu e & cQuote
'******** Code End **********

http://www.mvps.org/access/forms/frm0012.htm

Oct 5 '06 #2
Rex wrote:
In a table, I have number of records belonging to a particular ID now
if I enter a value in one of the fileds of this table I want it to be
copied in all the records belonging to this particluar ID. for example

ID Name
--------------------------
1 xyz
1
1
1
2
2
2
When I enter "xyz" for any one of the record of ID# 1.. I want all the
other records (with ID# 1) to have the name field as "xyz" so after
this.. the table would look like this

ID Name
--------------------------
1 xyz
1 xyz
1 xyz
1 xyz
2
2
2

I know this is not possible in table itself.. However I presume it
would be possible to do this in a form. But I dont know HOW

cheers
Rex
You could have a button on a form to call and update query. Let's say
your table name is "Table1". You want to update "NameFld" to the value
of "One" for id = 1.

Dim strSQL As String
Dim strText As String
Dim lngID As Long
Dim dbs As Database

strTest = "One" 'value to update
lngID = 1 'key to look for

'create dynamic sql statement
strSQL = "UPDATE Table1 SET Table1.NameFld = '" & _
strTest & & "' " & _
"WHERE Table1.ID = " & lngID

set dbs = Currentdb
With dbs
.Execute strSQL
msgbox "Updated " & .RecordsAffecte d & " records"
End WIth

set dbs = Nothing
Oct 5 '06 #3
Rex wrote:
I know this is not possible in table itself.. However I presume it
would be possible to do this in a form. But I dont know HOW
You *don't* want to do this in a form. Why not? Look at your schema.
Whether you have 1 or 4 or 50 records with an ID of 1, the Name is *always*
going to be xyz, or whatever you edit it to be in the future. (Name is not a
good name for a column by the way, as it's a reserved keyword.)

That's redundant data. You have a 1:1 relationship between ID and Name,
meaning it can go into a separate lookup table (the parent for this child
table) and either value can be placed in the current table as the foreign key.
That is, if you like to use surrogate keys. Otherwise, you can drop the
numeric ID column and keep the Name column natural key in the current table
and forget about creating a separate parent table, unless there are
additional attributes that need to be moved from the current table to the
parent table to normalize it.

If OTH you are in the middle of normalizing an imported spreadsheet and the
form is just one of the steps in transforming the data, then you could
instead use a single update query to set the corresponding values in all
records with an equijoin on the current table like this:

UPDATE tblCompanies AS C1 INNER JOIN
tblCompanies AS C2 ON C1.ID = C2.ID
SET C1.CoName = C2.CoName
WHERE (ISNULL(C2.CoNa me) = FALSE);

And you could then extract the records to create the lookup/parent table with
a make table query like this:

SELECT DISTINCT ID, CoName INTO tblCoNames
FROM tblCompanies;

But my recommendation is to transform an imported spreadsheet with this
structure by cutting out the intermediate step and just create the
lookup/parent table with a make table query like this (without first
assigning values to the empty columns):

SELECT DISTINCT ID, CoName INTO tblCoNames
FROM tblCompanies
WHERE (ISNULL(CoName) = FALSE);

If you like to use surrogate keys, that is. Skip the ID column if you prefer
natural keys.

--
Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200610/1

Oct 5 '06 #4
Granny Spitz via AccessMonster.c om wrote:
Rex wrote:

You *don't* want to do this in a form. Why not? Look at your schema.
Whether you have 1 or 4 or 50 records with an ID of 1, the Name is *always*
going to be xyz, or whatever you edit it to be in the future. (Name is not a
good name for a column by the way, as it's a reserved keyword.)
Which version? I looked at the reserved words for A97 and Name was not
a reserved word. In A2003 its not in the list of SQL reserved words.

Oct 5 '06 #5
salad wrote:
Which version? I looked at the reserved words for A97 and Name was not
a reserved word. In A2003 its not in the list of SQL reserved words.
It's on the list of reserved words for Access 97, 2000, 2002, and 2003.
http://support.microsoft.com/kb/109312/en-us and
http://support.microsoft.com/kb/209187/ and
http://support.microsoft.com/kb/286335/

But even if it's not a reserved word in an earlier version of Access, if you
ever plan to upgrade to a newer version, or have another application built in
a newer version link to these tables, or use ADO or DAO to connect to these
tables or queries, or use remote queries, then don't use Name as a column
name if you want to avoid bugs.

--
Message posted via http://www.accessmonster.com

Oct 5 '06 #6
Granny Spitz via AccessMonster.c om wrote:
salad wrote:
>>Which version? I looked at the reserved words for A97 and Name was not
a reserved word. In A2003 its not in the list of SQL reserved words.


It's on the list of reserved words for Access 97, 2000, 2002, and 2003.
http://support.microsoft.com/kb/109312/en-us and
http://support.microsoft.com/kb/209187/ and
http://support.microsoft.com/kb/286335/

But even if it's not a reserved word in an earlier version of Access, if you
ever plan to upgrade to a newer version, or have another application built in
a newer version link to these tables, or use ADO or DAO to connect to these
tables or queries, or use remote queries, then don't use Name as a column
name if you want to avoid bugs.
Thanks. In A97 help, the reserved words help file doesn't contain it,
nor 2003. Both referred to Jet SQL reserved words.

Funny they don't include the reserved words in the help files.
Oct 5 '06 #7
salad wrote:
Thanks. In A97 help, the reserved words help file doesn't contain it,
nor 2003. Both referred to Jet SQL reserved words.

Funny they don't include the reserved words in the help files.
There's two lists of reserved words, one for Access and one for Jet SQL.
Beats me why Microsoft can't combine the two into one list so that we only
have to check one list for what's off limits.

--
Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200610/1

Oct 5 '06 #8
"Granny Spitz via AccessMonster.c om" <u26473@uwewrot e in message
<67529f3e9364b@ uwe>:
salad wrote:
>Thanks. In A97 help, the reserved words help file doesn't contain
it, nor 2003. Both referred to Jet SQL reserved words.

Funny they don't include the reserved words in the help files.

There's two lists of reserved words, one for Access and one for Jet
SQL. Beats me why Microsoft can't combine the two into one list so
that we only have to check one list for what's off limits.
For those only using Jet, the list of reserved words in Access
wouldn't be very interesting, I guess.

--
Roy-Vidar
Oct 5 '06 #9
Believe me salad... using "name" as a field name is not a good idea.
Hell breaks loose as soon as you try an expression with that field on a
report...

salad schreef:
Granny Spitz via AccessMonster.c om wrote:
>Rex wrote:

You *don't* want to do this in a form. Why not? Look at your schema.
Whether you have 1 or 4 or 50 records with an ID of 1, the Name is
*always*
going to be xyz, or whatever you edit it to be in the future. (Name
is not a
good name for a column by the way, as it's a reserved keyword.)

Which version? I looked at the reserved words for A97 and Name was not
a reserved word. In A2003 its not in the list of SQL reserved words.
--
Bas Cost Budde
Holland
www.heuveltop.nl/BasCB/msac_index.html
Oct 6 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2841
by: Google Mike | last post by:
I have RH9 and am using the PHP and MySQL that came with it. I was doing fine with all manner of my web pages for this app until I started having this very strange problem. It's a work order mgmt system. I have 3 tables for the orders: TicketsOpen, TicketsVoided, and TicketsResolved. When one wants to void a ticket, they click it, choose Void, and it is copied to the TicketsVoided table, then removed from the TicketsOpen. And I can...
9
1502
by: Zoo Keeper | last post by:
For some reason, the Python preprocessing balks on the "\" line continuation character. Any ideas/thoughts? Is it just that my version of gcc is not supported? I don't "need" numeric in my current project, but it is a nice package to have! Apps that do not need to be compiled install and run fine. Actually, SQLite built and installed fine... Thanks, in advance.
6
683
by: Club-B42 | last post by:
i've compiled my programm using command "python setup.py py2exe >1" python script works fine, but .exe version fails with ===================================================================== D:\\Scripts\B-4-2\la2luncher\dist>la2launcher.exe Traceback (most recent call last): File "la2launcher.py", line 9, in ? File "config.pyc", line 11, in ? File "config.pyc", line 8, in u LookupError: no codec search functions registered: can't find...
3
2669
by: Jason | last post by:
In enterprise manager I am copying a table from one database to another. I am using the dts wizard to import the data. After I successfully import the data, I open both tables to compare the records to make sure they are the same. I right click on a field and click "last" for both tables. However, the record is different for both. If I do a query the record is still there but they do not show up in the same order. Why does'nt the...
2
2077
by: Vince | last post by:
I have a very specific problem to solve but I cannot find a data structure for it. I don't know if I am posting on the good newsgroup but I cannot find a software.design group. I would like to declare a smart structure initialized via a XML file. The goal of this structure is to store data from a smart card. My XML file describes the file structure of my smart card. On a smart card file are identified by number(sfid) and not by their...
5
2467
by: Nathan Sokalski | last post by:
I am writing an ASP.NET application in which I need to copy DataRows from one DataTable to another. When I use code such as the following: temprows = nodes.Select("state='PA'") temptable.Clear() For Each row As DataRow In temprows temptable.Rows.Add(row) Next
8
2066
by: Howard, Steven | last post by:
I have created a web app that stores and displays all the messages from my database maintenance jobs that run each night. The web app uses Java servlets and has PostgreSQL 7.0 as the back end. When the user requests the first page, he gets a list of all the servers with maintenance records in the database, and a drop down list of all the dates of maintenance records. If the user chooses a date first, then the app uses a prepared...
2
1594
by: Neil | last post by:
I'm using Access 2000 with a SQL 7 back end. I recently implemented some code in a form's AfterUpdate event which calls a stored procedure which copies the contents of the current record to a history table. The code works fine when the user edits and saves the record. However, if the user performs a Find and Replace, the code hangs. At first I thought the code was hanging because of multiple records being replaced. But when I debugged...
1
1557
by: Jan | last post by:
Hi: I've been tearing my hair out over this one for a few days; did a search of the archives and found similar questions but no real answers. Here goes: This is an application for a retail store. There are transactions, transaction details, and then, depending on the type of detail, related records in other tables. So when I'm entering a new transaction, I open a new form (dialog mode) in which additional detail is entered. I need...
0
10360
Oralloy
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...
1
10108
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,...
0
9960
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7510
isladogs
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...
0
6744
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();...
0
5532
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4064
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.