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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

writing unbound form record to table

Status
Not open for further replies.

jalgier

Programmer
Nov 7, 2001
15
US
Greetings,

My brain is a little frozen this morning. I have an unbound form that I need to have the records written to a table. I have a 'Submit' button that will perform the action (OnClick). Can someone please give me some direction in writing the code to submit a record to a table from an unbound form (the form consists of textboxes and some combo boxes).

As a sidenote, I also have a subform that will need to submit values to a table on the same form. Thanks in advance.
 
You need to use ADO for this. There's plenty of information already on this site on ADO and inserting records into tables so if you do a search on it i'm sure you'll come up with something. If not let me know and i'll try writing a bit of code for you. Mark

The key to immortality is to make a big impression in this life!!
 
Mark is right there is loads of info on this site and else where but as a starter you could try this :-

Dim cSql as String

cSql = "INSERT INTO MyTableName (nlField1,nlField2,cField3)"
csql = csql & "VALUES ("
csql = csql & txtNumber1.Text & ","
csql = csql & txtNumber2.Text & ","
csql = csql & "'" & txtString1.Text & "'"
csql = csql & ")"
Db.AdoConnection.Execute(cSql)

Be careful that strings are wrapped etc and it's always good practice to name the fields you are going to insert before the values.

Hope this helps you off,

Nick W
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top