473,464 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to Copy Records of a Form to Another?

29 New Member
Hi friends. I would like to copy certain records from a Form to another Form on 'Click'. The code works already but I don't know how to copy also other field. For the moment it copies only the first field
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdOrdered_Click()
  2. DoCmd.RunSQL "UPDATE Sales SET Sales.Action = 'Ordered'" & _
  3. "WHERE (Sales.Action)= 'On-Order' AND (Sales.[Transaction Type])= 'Sold Re-Order' and (Sales.Barcode_Of_Goods)='" & Me.Barcode_Goods & "'"
  4.  
  5. Me.Barcode_Goods.SetFocus
  6. Me.Barcode_Goods.SelStart = 0
  7. Me.Barcode_Goods.SelLength = Len(Me.Barcode_Goods.Text)
  8. RunCommand acCmdCopy
  9.  
  10. DoCmd.OpenForm "New Stock"
  11. RunCommand acCmdPaste
  12.  
  13.  
  14. Me.Requery
  15. End Sub
Apr 5 '14 #1
6 1347
jimatqsi
1,271 Recognized Expert Top Contributor
jazee,
Just follow Sales.Action = 'Ordered'" with a comma and the next field name and value.

You can learn a ton about putting together SQL statements if you use the SQL view of the query editor. Use the query editor to make a query such as this one and the go into SQL view and see what the code looks like.

Jim
Apr 5 '14 #2
jazee007
29 New Member
Sorry I haven't explain myself well. Infact its only the following code which need to be modify:
Expand|Select|Wrap|Line Numbers
  1.  Me.Barcode_Goods.SetFocus
  2. Me.Barcode_Goods.SelStart = 0
  3. Me.Barcode_Goods.SelLength = Len(Me.Barcode_Goods.Text)
  4. RunCommand acCmdCopy
  5.  
  6. DoCmd.OpenForm "New Stock"
  7. RunCommand acCmdPaste
Apr 6 '14 #3
jazee007
29 New Member
I need to copy the field "Barcode_Goods" as well as other fields. But for the moment I've been able to copy only the field "Barcode_Goods". Then I need to paste the records to the form "New Stock". Don't know how to do it. Thanks
Apr 6 '14 #4
jimatqsi
1,271 Recognized Expert Top Contributor
jazee,
I'm sorry, I believe the fault was mine. You did say from form to form and I zoomed in on the update statement. Completely wrong.

It's a wonder to me that the code you have pastes anything. You open the form but don't put the focus on any particular object. I suppose Barcode_Goods is the first field on the form so you hit the jackpot with that one.

You could try instead
Expand|Select|Wrap|Line Numbers
  1. Forms![New Stock]!Barcode_Goods.Text=me.Barcode_Goods.Text
  2.  
Forget the copy/paste, just do assignments from one form/field to the other.

Jim
Apr 6 '14 #5
jazee007
29 New Member
Let me described the form. I got a form named A and the field I need to copy is as follows:
Barcode_Goods
Sold
In_Hand

Then When I clicked on a button, the records copied will be paste in the Form "New Stock" in the following fields:
Goods
Actual_In_Hand
To_Order

In summary:
Barcode_Goods = Goods
Sold = Actual_In_Hand
In_Hand = To_Order

Sorry for my english
Apr 6 '14 #6
jimatqsi
1,271 Recognized Expert Top Contributor
So if you clicking a button on the form you call "A" you can refer to that form as ME. This would be the code to accomplish that.
Expand|Select|Wrap|Line Numbers
  1. Forms![New Stock]!Barcode_Goods.Text=me.Barcode_Goods.Text
  2. Forms![New Stock]!Sold.Text=me.Barcode_Actual_In_Hand.Text
  3. Forms![New Stock]!In_Hand.Text=me.To_Order.Text
Jim
Apr 6 '14 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Krasimir_Slaveykov | last post by:
Hello George, Monday, July 14, 2003, 11:46:06 AM, you wrote: Read this: http://www.mysql.com/doc/en/ANSI_diff_Sub-selects.html
5
by: Stan Shankman | last post by:
C# -- Visual Studio.Net – Windows Application Greetings all, How do I copy a Form’s image to a bitmap? – And do so before it gets to the screen. I haven’t been able to find anyone that knows...
5
by: Minfu Lu | last post by:
Is there anybody knows how to copy a form (actually the image of a form) to clipboard? Jason
6
by: Dale | last post by:
I'm not sure I'm even thinking about this the right way, but here goes: I have a table of users. Each one of these users may be associated with none, one, or many records in another table I call...
4
by: Nameless One | last post by:
Okay, it's been a while. I'm sure I used to know how to do this. I have two identical databases in structure and format. I want to copy records from a table in one database and add them to the...
1
by: colleen1980 | last post by:
I copy a form from another database into my database. I need help how to i link the table which is in another database with that form. Thank you.
2
by: nosipho | last post by:
Hello guys, I need to copy a database in SQL 2000 to another SQL2000 server. I tried backing up the database to a folder then restore it but it's not happening. Please help to know how to copy...
9
by: =?Utf-8?B?VGVycnk=?= | last post by:
Hi, Is it possible (w/o generating a gazillion errors) to copy a form in VS 2005 so that it can be modified and reused. In other words, I have a form, alot of which I wish to use in a different...
5
by: trixb | last post by:
Hello all, Here is what I need to do and need help with: I have a table that is feeding a chart in a report in Access. If this table has more than 50 records, the graph gets messy, and this is...
7
by: Laneyshia | last post by:
I'll cut to the chase: I'm writing a program written in Access Module. I never wrote in VBA code before although I do have programming experience. The idea is broken down into 3 steps. Step 1: ...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
jinu1996
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...
1
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...
0
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...
0
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...
0
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...
0
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 ...

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.