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 can i send the info from one field of a form to one field in a tab 1

Status
Not open for further replies.

Phideaux

Technical User
May 1, 2003
51
US
I need to find a method of sending information contained in the record displayed on a form to a field in a seperate table. I need to use a button click to send the vaule. what is the best way to do this?

thanks for the direction on this in advance

Phideaux

The mind is the best toy.
Play with someone else's often
 
If this is to add a new record to the table, on the buttons click event:

DoCmd.RunSQL "Insert Into table (Fieldname) Values ('" & Me!TextField & "')"

or if it is to update an existing record in the table:

DoCmd.RunSQL "Update table set field='" & Me!Textfield & "'" Where primarykey=value"

John
 
I'm just getting my feet wet into code so please bare with me. i entered the code you provided into my on click event.
DoCmd.RunSQL "Insert Into table (Fieldname) Values ('" & Me!TextField & "')"

Wy Target table is "workorders" and the destination field is "MaintCntl#" what is the proper syntax for the Field name?

The source data comes from a form drawing its data from table named "Equipment" and the field in the record is is "MaintCntl #"
I'm getting errors and I've tried several variants with errors in each of them. ( Obviously my code writing skill is in it's infancy :) )

The source records may number dozens and i only want to send the information to the target table one at a time as each is selected for assignment. i've been sending all of the records over at the same time but that is creating problems in duplication. thanks for the first response! it helped. i'm still not working correctly, help.

phideaux
my email
Kwrowlan@olypen.com

The mind is the best toy.
Play with someone else's often
 
DoCmd.RunSQL "Insert Into Workorders (Maintcntl#) Values ('" & Me!TextField & "')"

What the above code does is inserts a new record into the mainctl# field of the table Workorders with the value in the control called TextField on a textbox on the current form (hence the Me! prefix), rather than take it from another table directly (it is possible to do that as well, but i won't blind you with science here yet...)

One thing though: If you got the syntax correct as per above, but it still doesn't work, try renaming the field in the table and remove the hash character #. This is because it is used by Access to delimit date variables, and as a result only having one will confuse it, not finding the closing character.

John
 
John, I ended up renaming the fields. and reviewing several others related questions to understand the syntax and finally got it right!!!! Many thanks for your direction. :)

it was an excellent learning experience!

The mind is the best toy.
Play with someone else's often
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top