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!

add record to table from form

Status
Not open for further replies.

haytatreides

IS-IT--Management
Oct 14, 2003
94
US
I have a form that lists two tables, and pulls data from a third. What i want to do is this, i want to add a record to the third table, inputing variables from my form into the fields. i just need to know how to add the data to the fields. any help would be appreciated!

hayt
 
Put the data in the third table in a subform which is linked appropriately to the main form's table/query source. If I understand you correctly, you want to take values that are in the other tables and displayed on your form and include those values in a new row. (Although you are then duplicating data in multiple tables.)

You could set the default values of those controls in your subform to be the values in the appropriate controls on the main form. Or you could use the BeforeInsert property of the subform to set the values of those controls on the subform to the matching values on the main form.
 
the issue is that i am taking data from an "assignment" table, and putting it into a "schedule of assignments" table, where the schedule criteria is defined in a "schedule" table. I am only copying some schedule criteria, and the assignment number to the schedule of assignment table. basically, the user selects the assignemnt number and schedule number, and clicks "add". I want code to then pull data from both tables, and make a new record in the schedule of assignments, assigning the assignment and schedule numbers to the new record (along with other criteria). I have variables pulling the data i need, i just need to know the code to add the variables to the fields in my table.
I do not have controls bound to the fields, and i kinda want to steer away from them, cause I may need to add more fields as my requirments may change.

it is as big a pain in the ass as it sounds. hehe.

what i have is
docmd.opentable "MyTable", acNormalView
DoCmd.GoToRecord , , acNewRec
Field1 = Variable1
Field2 = Variable2
.
.
.
DoCmd.Close acTable, "MyTable", acSaveYes

It is the field = variable part that i dont know how to do.

hayt
 
i got it! i have no idea why it didnt work before, but i opened the recordset as openstatic, lockoptimistic and cmdtabledirect, and that worked. no idea why!

hayt

thanks everyone!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top