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

How would you code a txtbox in Access to enter data into a Access tbl

Status
Not open for further replies.

Nate16

Programmer
Jul 9, 2002
17
0
0
CA
Hi

I am trying to make a txtbox for access database enter data into seperate Excel and an Access tbls....Would I have to link the two tables or would I have an easier time just doing it in code, and if I did it in code where would I start...PLEASE HELP ME! <:(
 
Well if you code it:

Dim Rst As Recordset
Dim Db As Database
Set Db = CurrentDb
Set Rst = Db.OpenRecordset(&quot;Tbl_MyTable&quot;, dbOpenDynaset)
Rst.AddNew
Rst.Fields(&quot;MyField&quot;) = TxtBox123.Value
Rst.Fields(&quot;Any other field&quot;) = txtWhatever.value
Rst.update
Rst.Close

Let me know if it helps &quot;The greatest risk, is not taking one.&quot;
 
Thanks but there is one problem what the code did was it only could move the text between the different fields in access rather than two different tbls. It probably could be modified to do just that... Thanks for your help and your advice....If you dance on hot coals you'll get burned....Ya it sounds pretty stupid but who ever said I could give advice
 
You can use SQL with an INSERT to take data from one table and insert it into another table. Is that what you wish to do??

Rollie@bwsys.net
 
for 2 different tables do this:
Dim Rst As Recordset
Dim Db As Database
Set Db = CurrentDb
Set Rst = Db.OpenRecordset(&quot;Tbl_MyTable&quot;, dbOpenDynaset)
Rst.AddNew
Rst.Fields(&quot;MyField&quot;) = TxtBox123.Value
Rst.Fields(&quot;Any other field&quot;) = txtWhatever.value
Rst.update
Rst.Close

Dim Rst2 As Recordset
Dim Db2 As Database
Set Db2 = CurrentDb
Set Rst2 =Db2.OpenRecordset(&quot;Tbl_MySecondtbl, dbOpenDynaset)
Rst2AddNew
Rst2Fields(&quot;MyField&quot;) = TxtBox123.Value
Rst2Fields(&quot;Any other field&quot;) = txtWhatever.value
Rst2update
Rst2Close &quot;The greatest risk, is not taking one.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top