Insert Query - MS Access/VBA (1 Viewer)

AunN

Registered User.
Local time
Today, 02:33
Joined
Dec 10, 2011
Messages
16
Dear Programmers!!

Here is code to insert record into table. But i neither get any error message nor record is inserted into table. Please help me out. I'm very new to Access Database Development so need your kind guidance.

Private Sub Form_Click()
Dim dbs As Database
' Modify this line to include the path to Northwind
' on your computer.
Set dbs = OpenDatabase("C:\database\Ali Video Store.mdb")

' Create a new record in the Employees table. The
' first name is Harry, the last name is Washington,
' and the job title is Trainee.
dbs.Execute " INSERT INTO TransMaster "(tm_Customer,tm_DateOut,tm_Employee,tm_MovieID ) VALUES ('9', #02/02/2009#, '2', '2');"

dbs.Close

End Sub

tm_Customer, tm_Employee,tm_MovieID are integer variables. TransMaster has primary key tm_Number which is autonumber field.

Please solve my problem!!
 

Alansidman

AWF VIP
Local time
Today, 04:33
Joined
Jul 31, 2008
Messages
1,493
I don't think that you need to have the single quote marks around integer values.

Try this:
Code:
dbs.Execute " INSERT INTO TransMaster "(tm_Customer,tm_DateOut,tm_Employee,tm_MovieI D ) VALUES (9, #02/02/2009#, 2, 2);"

Alan
 

AunN

Registered User.
Local time
Today, 02:33
Joined
Dec 10, 2011
Messages
16
Alan!!

I have tried this command as you stated but no way out..neither the record enters the table nor i get any kind of message by dbms.

Please re-look my problem!!
 

Users who are viewing this thread

Top Bottom