Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / April 2006

Tip: Looking for answers? Try searching our database.

append data to a table using VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brian - 02 Feb 2006 17:09 GMT
Hello.  I have two public varibles in a module that have a number assigned to
each one.  I also have a form where, when i press a button, i want the values
of each varible added to a table.  The varibles are Public Record As Integer
and Public License As Integer.  
The table has two fields, Hardware ID and License ID.  I need Record to be
added to Hardware ID and License to be added to License ID.  
It matters not to me how this gets done, i just need it to work.

Thanks for any help!!

Brian
Ofer - 02 Feb 2006 18:13 GMT
Try

Docmd.RunSql "INSERT INTO TableName ([Hardware ID] , [License ID]) VALUES ("
& Record  & ", " & License & ")"

Signature

\\// Live Long and Prosper \\//
BS"D

> Hello.  I have two public varibles in a module that have a number assigned to
> each one.  I also have a form where, when i press a button, i want the values
[quoted text clipped - 7 lines]
>
> Brian
Brian - 02 Feb 2006 18:35 GMT
Thanks alot!!  Works great :)

Brian

> Try
>
[quoted text clipped - 12 lines]
> >
> > Brian
Onne - 24 Apr 2006 13:16 GMT
Hi!

I tried to use the same code:

Docmd.RunSql "INSERT INTO TableName ([HardwareName] , [License ID]) VALUES
("& tbName  & ", " & License & ")"

For numbers this works fine, although for inserting text boxes into a table
field (data type: text) it doesn't.
I receive a prompt to enter "Parameter Value". When I insert the text in
this prompt it does insert it into the table. But of course this isn't a good
solution when you have to insert all the data via a popup screen...

Who can help me?
Thanks in advance!
Onne

> Thanks alot!!  Works great :)
>
[quoted text clipped - 16 lines]
> > >
> > > Brian
Marshall Barton - 02 Feb 2006 18:38 GMT
>Hello.  I have two public varibles in a module that have a number assigned to
>each one.  I also have a form where, when i press a button, i want the values
[quoted text clipped - 3 lines]
>added to Hardware ID and License to be added to License ID.  
>It matters not to me how this gets done, i just need it to work.

One way is to open a recorset to the table:

Dim db As Database
Dim rs As DAO.Recordset
Set db = CurerntDb()
Set rs = db.OpenRecordset("thetable")
rs.AddNew
    rs![Hardware ID] = Record
    rs![License ID] = License
rs.Update
rs.Close :  Set rs = Nothing
Set db = Nothing

Signature

Marsh
MVP [MS Access]

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.