Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to record data from a text box (form) to a field (table)

Status
Not open for further replies.

fuldingo

Programmer
Jul 1, 2002
12
PK
I have a form with differents text boxes, etc. I´m querying some information of three differents tables in order to show i.e product name, product codes, customer code, customer name, and product price. I want to give the option that the user can modify the product price or even stay the default product price, but in any case i want to store the product price in other field from other table called "transactions". I don´t know how to do that, i think that is using some line command from VB.
Thank you.
 
If your form is based on a query, and that query is made of more then one table, you can't update it automatically. One solution would be to insert or update the row automatically with SQL on a before update event or an on click event for a submit button. I just gave an example of how to do that in the post "How to Map Many tables to one Access Form?", it might help.

HTH!

-Brad

 
Hello Fuldigo...

Here is my suggestion.. Lets say we had 3 text boxes called t1, t2, t3 and Mr. User enters the info requried and he clicks on a command button called Add on ze_Form and we want to store it into table1. :)

Therefore we can do the following:

Option Compare Database
Option Explicit
-----------------------------------------------------
Private Sub ze_Form!Add_Click() 'You can also just use "Add"

Dim dbs As DAO.Database

Set dbs = CurrentDb

dbs.Execute "INSERT INTO table1 VALUES ('" + t1.Value + "','" + t2.Value + "','" + "" + t3.Value + "')", dbFailOnError


End Sub

We are assuming that the columns are in the order we want ... since the text to be executed is just an SQL statement we can also refer to the column names in which to add the data ... < there is a nice Quick sql insert statements tutorial on
Hope zis helps ...

Good luck :)
Taha
thamiral@uwo.ca
 
Thank to blarson0 and taha60 for you response. But i´m still having the same problem but i think that is my fault. I forgot to tell you that i´m workin with subforms, i mean, i´ve got a subform with a combo box which Row Source is a query from , let´s say , Table A. With the data of this query, i´m filling the combo box itself and three different text boxes. Now, each time that i play the query using the combo box, i insert a new record in Table B that contains too the Child Field. With a combo box is easy to update the value that contains to TAble B using Record Source, but my problem is how to update the value from a text box of this subform to Table B. Also, reviewing the wbe site giving by Taha60 (SQL tutorial), i know too, that what i need is perform a UPDATE instead an INSERT, but i´ve tried unsuccesfully.

Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top