473,796 Members | 2,460 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I move input data from one place in a form to a specified field in a table.

6 New Member
I am trying to design a form in which a category (field in a table) is selected from a combo box, then a value for that category is entered in a form field. I want that value to be placed in the field selected from the drop down list in the combo box. It would be like what happens when a bookkeeper selects an account field from a list and then enters a value for it. The value is then appended to the specified account field. I think this should be something easy, but I can't figure it out. I have made forms where an input field matches a table column, but I can't figure out how to specify the column (field) and then have the value go there. I would like a user to have just a couple of places to deal with in data entry instead of a massive form. I am pretty inexperienced with Access. Maybe I know only enough to be dangerous. :-/ Thanks.

I have Access 2003 running on XP Pro
Nov 8 '06 #1
14 1933
MMcCarthy
14,534 Recognized Expert Moderator MVP
I am trying to design a form in which a category (field in a table) is selected from a combo box, then a value for that category is entered in a form field. I want that value to be placed in the field selected from the drop down list in the combo box. It would be like what happens when a bookkeeper selects an account field from a list and then enters a value for it. The value is then appended to the specified account field. I think this should be something easy, but I can't figure it out. I have made forms where an input field matches a table column, but I can't figure out how to specify the column (field) and then have the value go there. I would like a user to have just a couple of places to deal with in data entry instead of a massive form. I am pretty inexperienced with Access. Maybe I know only enough to be dangerous. :-/ Thanks.

I have Access 2003 running on XP Pro
You will need to create an command button and in the On Click event put something like the following:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub commandBtnName_OnClick()
  3.  
  4.   DoCmd.RunSQL "UPDATE TableName SET " & Me.ComboboxName & _
  5.       "=" & Me.textboxName & WHERE <you will have to identify the record here that you want to be updated> ;"
  6.  
  7. End Sub
  8.  
  9.  
Nov 8 '06 #2
rbowman40
6 New Member
Thank you. I'll try that, although I know next to nothing about VB.
Nov 8 '06 #3
MMcCarthy
14,534 Recognized Expert Moderator MVP
Thank you. I'll try that, although I know next to nothing about VB.
Make an attempt and if it doesn't work post the code here and we will try to correct it for you.
Nov 9 '06 #4
rbowman40
6 New Member
OK . . . I created a command button on my form named Go. The idea is to select an acct from a combobox named Account Name and then enter an amount in a textbox named Amount which is to be transferred to an account field (matching Account Name) in a table named TransDistributi on. Here's the code I wrote following your example as best I could:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Go_OnClick()
  2.  
  3.     DoCmd.RunSQL "UPDATE Transdistribution SET" & Me.Account_Name & "=" & Me.Amount & Me.TransDistribution
  4.  
  5. End Sub
  6.  


I assume that in the OnClick property for Go, I am to choose [Event Procedure] or am I to name it? I tried "Private Sub Go_OnClick()" but Access thought I was trying to run a macro. Is there some way to do this with a macro?
Nov 10 '06 #5
NeoPa
32,579 Recognized Expert Moderator MVP
The code looks mainly good.
However :
There should be a space after SET
There needs to be single-quotes around the new data
The name of the field (if there's any possibility of it containing spaces or clashing with reserved words) should have [] around it.
Try this :-
Expand|Select|Wrap|Line Numbers
  1. Private Sub Go_OnClick()
  2.     DoCmd.RunSQL "UPDATE Transdistribution SET [" & Me.Account_Name & "]='" & Me.Amount & Me.TransDistribution & "'"
  3. End Sub
Nov 10 '06 #6
NeoPa
32,579 Recognized Expert Moderator MVP
Just a note.
I don't know what you were trying to do with the
Expand|Select|Wrap|Line Numbers
  1. "=" & Me.Amount & Me.TransDistribution
bit so I just copied it straight across.
In my version I added quotes as I saw you had the '&' bit in there for string concatenation.
If this was not intended and you wanted just the value of the amount, then lose the quotes AND the ' & Me.TransDistrib ution' bits.
Nov 10 '06 #7
MMcCarthy
14,534 Recognized Expert Moderator MVP
OK . . . I created a command button on my form named Go. The idea is to select an acct from a combobox named Account Name and then enter an amount in a textbox named Amount which is to be transferred to an account field (matching Account Name) in a table named TransDistributi on. Here's the code I wrote following your example as best I could:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Go_OnClick()
  2.  
  3. DoCmd.RunSQL "UPDATE Transdistribution SET Account=" &  Me.Amount & " WHERE Account_Name=" & Me.Account_Name ";"
  4.  
  5. End Sub
  6.  


This code assumes that the table name is Transdistributi on and it contains two fields named Account which will be set with the Amount value and Account_Name which will equal the combo box value in the record being updated.

I assume that in the OnClick property for Go, I am to choose [Event Procedure]
yes
Nov 10 '06 #8
rbowman40
6 New Member
OK.... the code now looks like this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Go_OnClick()
  2.     DoCmd.RunSQL "UPDATE Transdistribution SET [" & Me.Account_Name & "]= & Me.Amount"
  3. End Sub
Did I do that right? Maybe I'm just way in over my head. I have some JPEG's of the table, form, and properties box for the go button. I will try to send them in a subsequent post, but have not quite figured out the "insert image" procedure the button above not withstanding. I wiped out this whole message once trying to insert the images, so I will send this separately. Thanks.
Nov 10 '06 #9
rbowman40
6 New Member
Trying to insert the images. Copy and Paste doesn't seem to work.
Nov 10 '06 #10

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

Similar topics

0
1808
by: Willoughby Bridge | last post by:
Hi - Having trouble getting a multipart series of forms to move to the next form. The problem line is: <form method="post" enctype="multipart/form-data" action="Data_Form1.php"> If the "action" parameter is set to the current form (Data_Form1.php) then the data posts to the table correctly, but it does not move to the next form If the "action" parameter is set to the next form in the series then by clicking "submit" it moves to the...
4
3021
by: Justin Lebar | last post by:
Sorry about the huge post, but I think this is the amount of information necessary for someone to help me with a good answer. I'm writing a statistical analysis program in ASP.net and MSSQL7 that analyzes data that I've collected from my business's webpage and the hits it's collecting from the various pay-per-click (PPC) engines. I've arrived at problems writing a SQL call to generate certain statistics. Whenever someone enters our...
6
2507
by: Robin S. | last post by:
**Eric and Salad - thank you both for the polite kick in the butt. I hope I've done a better job of explaining myself below. I am trying to produce a form to add products to a table (new products). Tables: tblCategoryDetails CategoryID SpecID
3
1885
by: Eric | last post by:
When i run my query it transfer last 4 digits of account number from one table to another and its wrong. There are two tables one i use for parsing. Second thru query i use to move data from temp table to actual table with some little changes in temp table. I use the same code in two different databases One database works fine and another database wont move the account number with 9 digit size. Difference is only the structre of text files...
1
1259
by: AMDRIT | last post by:
Occasionally I try my hand at a simple data storage engine. Today I ran across an article on the web http://msdn2.microsoft.com/en-us/library/aa289151(vs.71).aspx, and it got me thinking again. There doesn't seem to be a definative source, at least on in layman terms, on this subject. Here is what I believe to know so far. (As if I was to model after SQL Server).
0
2495
by: prasenjit2007 | last post by:
I have a main form for inputing the (to/from/mesg/file) with the following code:- <html> <body> <table> <tr> <td>To:</td> <td><input type="text" name="to" size="50" value="pras_sandilya@rediffmail.com"></td> </tr>
1
4008
by: SkipNRun | last post by:
I am a novice when comes to JavaScript, AJAX. I am working on a form, which will allow users to update their contact information. In order to make the form flexible, I need to use pull down list. Depends on the pull down list selection, I use script.aculo.us to validate the user input before submit and pass the necessary data, such as contact type, contact information and ranking to a php program for updating. This form should allow multiple...
3
2756
by: Guig | last post by:
Hi, I have a problem with one of my form. I want to record some data in a table by using a form. One of those data it is the time and I want to use an input mask to be sure that everyone will enter the data in the same way. There is my problem: After the first digit I'm entering in the field, the message error "The value you entered isn't appropriate for the input mask '99:00\ >LL;0;_' specified for this field" appears. I'm pressing "OK"...
21
7989
by: DanicaDear | last post by:
I've been trying to figure this out for three weeks. I've been sleeping on it. Not getting answers, just losing sleep. ;-) In a table, I have a field COMPANY_EMAIL. In this field I want to allow up to 8 characters, use the same domain always, and in a form be able to click and open an email to this customer. I have tried this in numerous ways, and I think it's occuring to me finally I can't do everything in one place. I think I might...
0
9683
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
10457
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...
0
10231
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 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...
0
9054
agi2029
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...
1
7550
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
5443
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
5576
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4119
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
3
2927
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.