Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 681
  • Last Modified:

SQL insert into statement question (access 2007)

is there a way to include my variable ts with whatever the user types in the parameter box?
thank you

Dim ts As String
ts = Now
DoCmd.RunSQL "INSERT INTO NotesTable([Notes])VALUES ([Enter your note])"
0
TSTechNA
Asked:
TSTechNA
  • 2
1 Solution
 
orcicCommented:
Dim ts As String
ts = "Your Note"
DoCmd.RunSQL "INSERT INTO NotesTable([Notes])VALUES ('" & ts & "')"
0
 
Rey Obrero (Capricorn1)Commented:
just a slight correction

----------------------------------------------------------------v-put a space
DoCmd.RunSQL "INSERT INTO NotesTable([Notes]) VALUES ('" & ts & "')"
0
 
TSTechNAAuthor Commented:
awesome, that works but could you explain why it works? i don't really understand the syntax

also is there a way to include ts and my parameter of ([Enter your note]) together? so that they will be 1 record? basically a time/date stamped comment/note is all i am trying to do

thank you
0
 
orcicCommented:
DoCmd.RunSQL "INSERT INTO NotesTable([Notes]) VALUES ('" & ts & " " & now() & "')"
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now