473,609 Members | 2,296 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pushing form fields to table

164 New Member
Perhaps this is a no brainer...I have a database that is comprised of just one form and one table. This was made quite a while ago for someone, and now they want to do some more with it.

Now they want to have a separate table that holds some of the same information as the original. There are a ton of records in here, and what I was wondering is if there was a button I could put on the form for, whichever record they were on while browsing the form they could hit the button and would send certain (pre defined fields) from that record over to another table.

Reason being: the form right now has all their current customers.. the new form they want is to add new customers in a different way as well as adding SOME of the customers from the original form.. So I thought I would give them the control of who they want to add to the new table by adding this button.

So what I am wondering is how to put the button on there to pass certain fields to a given table.

I do hope this makes sense. I am trying my hardest to get the words to come
out correctly. I would be happy to elaborate!



Thanks in advance!
Jan 22 '08 #1
3 3002
PianoMan64
374 Recognized Expert Contributor
yes, that is very easy and it is very possible.

the way that you would do it, is simply open the other table up using VBA code and then when you push the button on the current record, it will copy those select fields over to the new table.

Step 1.

Create a button with the label "Copy Customer" with the controlName called CopyCustomer

Step 2.

scroll down the properties list of the button control until you see the On Click event.

click on the ... and select Code Builder.

Step 3.

Copy and paste the following code for the button.

Expand|Select|Wrap|Line Numbers
  1.  
  2.        Dim MyDB As DAO.Database
  3.        Dim MyRS As DAO.Recordset
  4.  
  5.        Set MyDB = CurrentDb()
  6.        Set MyRS = MyDB.OpenRecordset("SELECT * FROM [TABLENAME]", dbOpenDynaset)
  7.  
  8.         With MyRS
  9.  
  10.                .AddNew
  11.                !FieldNameInTable = Me.ControlNameOnForm.Value
  12.                .Update
  13.         End With
  14.         MyRS.Close
  15.         MyDB.Close
  16.         Set MyRS = Nothing
  17.         Set MyDB = Nothing
  18.  
  19.  
Please NOTE that [TABLENAME] needs to be replaced with the accual table name that the data will be pushed too. also you will need to add the names of the fields in the table and reference the controls on the form. please note the syntax of !fieldname ----- and the control name of me.ControlName. value this will read the value of the controlname on the form.

If you have any questions, please feel free to email me at me@joepottschmi dt.com

Hope that helps,

Joe P.
Jan 22 '08 #2
mbatestblrock
164 New Member
yes, that is very easy and it is very possible.

the way that you would do it, is simply open the other table up using VBA code and then when you push the button on the current record, it will copy those select fields over to the new table.

Step 1.

Create a button with the label "Copy Customer" with the controlName called CopyCustomer

Step 2.

scroll down the properties list of the button control until you see the On Click event.

click on the ... and select Code Builder.

Step 3.

Copy and paste the following code for the button.

Expand|Select|Wrap|Line Numbers
  1.  
  2.        Dim MyDB As DAO.Database
  3.        Dim MyRS As DAO.Recordset
  4.  
  5.        Set MyDB = CurrentDb()
  6.        Set MyRS = MyDB.OpenRecordset("SELECT * FROM [TABLENAME]", dbOpenDynaset)
  7.  
  8.         With MyRS
  9.  
  10.                .AddNew
  11.                !FieldNameInTable = Me.ControlNameOnForm.Value
  12.                .Update
  13.         End With
  14.         MyRS.Close
  15.         MyDB.Close
  16.         Set MyRS = Nothing
  17.         Set MyDB = Nothing
  18.  
  19.  
Please NOTE that [TABLENAME] needs to be replaced with the accual table name that the data will be pushed too. also you will need to add the names of the fields in the table and reference the controls on the form. please note the syntax of !fieldname ----- and the control name of me.ControlName. value this will read the value of the controlname on the form.

If you have any questions, please feel free to email me at me@joepottschmi dt.com

Hope that helps,

Joe P.

Thank you so much! I will be giving this the ole' college try this evening. Again, thanks a ton!
Jan 22 '08 #3
mbatestblrock
164 New Member
Thank you so much! I will be giving this the ole' college try this evening. Again, thanks a ton!
Okay, so I got it working.. and I know this may be pushing it but here is my dilemma.. I was hoping someone may have a solution for me. the form that this button is on was and still is being used to filling in information and it has a button on it to export everything to a word tmeplate to print out.. Now they want to he database to be used for more stuff,.

the button works fine but here is my problem. the form i have created has a sub form in it.

so main part of form consists of

CustID (auto num) Name, Address.

and the sub form consists of
CustID (pulled from above) Name, (also pulled from above), Date of order, Amount paid, Amount Due.


so when I hit the copy button what i want it to do is push data from that form into

Main form: Name, Address
Sub form: * all fields

So I am running into the problem of only being able to push fields to one table, which I am sure there is a workaround. but the bigger problem I see is this:

In the form with the copy customer button, If the same customer is in there twice I would like the copy procedure to not make a new record but to insert a new record into the sub form. and on the same note, I dont know what to do as far as a situation where there would happen to two customers with the same name??

I think I may be hosed...? and I hope this all made sense to everyone, I am finding it hard to explain.

If it helps at all, the person I am doing this for starts with the form with the copy button on it for entering in any new customers, this is why I am so concerned about getting the copy button to work, just to make it easier for them so they dont have to open up a new form to enter some of the same information they just did (also possibly entering a wrong number here or there)

I dont know if it possible to have something like this happen when the button is clicked:

a window pop up and have the option to select from a list of customers in the new form to append the results to, or to make a new customer?
-that might be a bit complex, and I don't even know if it can be done, but I thought it was worth a shot.


SO, with that being said, if ANYONE has any advice for me... that'd be great!
Jan 27 '08 #4

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

Similar topics

2
4072
by: Nick | last post by:
Loop to create an array from a dynamic form. I'm having trouble with an application, and I'll try to explain it as clearly as possible: 1. I have a form with two fields, say Apples and Oranges. The user selects from a drop down menu, between 1-10 of each and clicks submit. The resulting page will display a NEW form, with rows and a list of fields for the amount of each items selected.
3
1640
by: Mike Whittemore | last post by:
I am trying to convert an HTML table into a list of name-value pairs, one pair per field in the table. I believe my XSLT is correct, but I've tried both Xalan and Saxon, which both fail with different results. Below I've listed my HTML input, my expected XML output, my XSLT, and the actual output from both Saxon and Xalan. Thanks in advance. HTML Input ---------- <html>
7
2342
by: Aravind | last post by:
Hi folks. I have 2 forms, frmBorrow and frmHistory frmBorrow has an unbound multi-column combo box (cboMember) and 7 unbound text boxes (MemNo, MemName, MemIC, MemType, CourseFaculty, Borrow, Due) frmHistory has the following text boxes: MemName, Borrow, Due
0
2012
by: Jason | last post by:
I have a primary form which is used to enter/edit data in a table named Test_Results. On this primary form there is a subform which displays site addresses. This subform is linked to the primary form by field named TestID. The subform is used just for displaying site address data, data which is stored in another table named Total_Site_Address. In the Total_Site_Address table there are numerous fields that form the site addresses...
1
3543
by: meganrobertson22 | last post by:
hi everybody- what is the best way to add data from one form to another? i have 2 tables: person and contract. here are some of the fields. table: person personid (autonumber and primary key) ss#
3
2330
by: Bill | last post by:
I'm using the POST method to submit a simple form html page with yes/no and checkbox fields to an asp response page which stores the values in a new dim string, then uses it to build a new table using ADO. I'm getting sometimes correct values, sometimes null values (when I know I pass a valid default value) and other times multiple values! I know what the values coming over are because I do a response.write to see it before the error...
3
1553
by: bronen | last post by:
I need a step by step instruction to do the following (i'm a beginner): 1) I have a form with two unbound text boxes. ProjectNumber, ProjectName 2) I have a form called "GoTeam" with two regular text boxes assigned to fields in the table labeled "ProjectNumber" and ProjectName. I want to have a command button on the first Form that takes the data and "sends" the data to the GoTeam form and populates the table for GoTeam. So if...
2
2315
by: adwest | last post by:
Forgive me if this is a foolish question. I "play" in Access and have only created a few rather simple relational databases. My knowledge and experience is limited. I have no formal training, just picked up a few books and have gone from there... I'm not sure how to relate my question using the accepted shorthand, so I'm afraid this will be a narrative description. I am using Access 2003. The database is for property management. I have...
3
2205
by: ibeehbk | last post by:
Hi. I have a form made in xhtml. I test via vbscript to make sure none of the fields are empty and properly formatted (ie email). All the regular fields work. However, I have two drop down menus that are SELECT elements (javascript-- one named arrivalcity and one named returncity). Basically they ask for a departure and return city and another menu appears with options based on that city. I can't seem to get the input from these fields in the...
0
8126
marktang
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...
0
8065
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8394
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
6052
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
5507
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
4013
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4074
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1379
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.