append data to a table using VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
Try

Docmd.RunSql "INSERT INTO TableName ([Hardware ID] , [License ID]) VALUES ("
& Record & ", " & License & ")"
 
Thanks alot!! Works great :)

Brian

Ofer said:
Try

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


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


Brian said:
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
 
Brian said:
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.


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
 
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

Brian said:
Thanks alot!! Works great :)

Brian

Ofer said:
Try

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


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


Brian said:
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
 
Back
Top