Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2004
    Posts
    7

    Unanswered: how to assign form item value into VBA sql

    Hi Friends,

    I developed a data enter form in access 2007
    The form item value as
    strCOMMENTS = Me.COMMENTS

    MsgBox strCOMMENTS

    I can capture strComments value.
    However, I put these items in sql as
    DoCmd****nSQL "insert into test values (strComments);"

    but I got a enter parameter value box. I need to put a value in box and data is added into database.

    How to avoid parameter box display during VBA code running?
    Thanks
    Jim

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Try this (I would expect you to have to specify the field, unless there's only one in the table):

    DoCmd****nSQL "insert into test values ('" & strComments & "');"

    If the comments might contain a single quote, that will have to be modified. More info in this tutorial:

    Building SQL in VBA
    Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •