Insert Into Query from Form

aqif

Registered User.
Local time
Today, 08:37
Joined
Jul 9, 2001
Messages
158
Hi There...
smile.gif


I am trying to run an Append query like this

Dim Str1,Str2 as String

Str1 = Date()
Str2 = Me.ItemId

DoCmd.RunSql("Insert into TableName(OrderDate,ItemId) values (str1,str2)")

End

When I try to run this query Access doesnot recognise Str1 and Str2 and prompts me for value. I want to know that how can I do that.

By the way If I try like below it works fine
DoCmd.RunSql("Insert into TableName(OrderDate,ItemId) values (Forms!MyForm!TxtDate,Forms!MyForm!TxtItem)")

But inserting values like this will not solve my problem as my requirement is different in actual work.

Any suggesstions?

Cheers!
Aqif
 

Users who are viewing this thread

Back
Top Bottom