please correct me

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • creative1
    Contributor
    • Sep 2007
    • 274

    please correct me

    hi every one I was using a query to insert some data and it worked fine. I had to add a new fields (Extension stored in...... txtvendor(0).te xt, its a numeric value) on form.It work fine if remove extension and it relavant field form thr query. I am getting error message Syntax error I can't pick why
    here is my query

    [code=vb]RS.Open "Insert into Vendor(account_ no,customer,con tact_person,add ress,city,posta l_code,province ,phone_number,E xtension,licenc e_no,gst_no,pst _no,terms,descr iption,status) values (" & Trim$(txtVendor (1).Text) & ",'" & Trim$(txtVendor (2).Text) & "','" & Trim$(txtVendor (3).Text) & "','" & Trim$(txtVendor (4).Text) & "','" & Trim$(txtVendor (5).Text) & "','" & Trim$(txtVendor (6).Text) & "','" & Trim$(txtVendor (7).Text) & "','" & Trim$(txtVendor (8).Text) & "'," & Trim$(txtVendor (0).Text) & ",'" & Trim$(txtVendor (9).Text) & "','" & Trim$(txtVendor (10).Text) & "','" & Trim$(txtVendor (11).Text) & "'," & Trim$(txtVendor (12).Text) & ",'" & Trim$(txtVendor (13).Text) & "','" & Trim$(txtVendor (14).Text) & "')", Conn, adOpenStatic, adLockOptimisti c[/code]
    thanks in advance
    Last edited by debasisdas; Nov 23 '07, 04:38 AM. Reason: Formatted using code tags
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    can you post what exactly is the error message.

    Comment

    • QVeen72
      Recognized Expert Top Contributor
      • Oct 2006
      • 1445

      #3
      Hi,

      You dont need to open a Recordset for "Insert" Statements,
      You Have to Execute Them on Connection or Command Object.
      Say:

      Conn.Execute "Insert Into ....."

      Regards
      Veena

      Comment

      • lotus18
        Contributor
        • Nov 2007
        • 865

        #4
        Originally posted by QVeen72
        Hi,

        You dont need to open a Recordset for "Insert" Statements,
        You Have to Execute Them on Connection or Command Object.
        Say:

        Conn.Execute "Insert Into ....."

        Regards
        Veena
        Hi Veena

        I would like to respond with your post. I think you can still use the Recordset.Open for inserting or updating sql statements.

        For creative1

        Try this:

        [code=vb]
        RS.Open "Insert into Vendor([account_no],[customer],[contact_person],[address], [city],[postal_code],[province],[phone_number],[Extension],[licence_no],[gst_no],[pst_no],[terms],[description],[status]) values ('" & Trim$(txtVendor (1).Text) & "','" & Trim$(txtVendor (2).Text) & "','" & Trim$(txtVendor (3).Text) & "','" & Trim$(txtVendor (4).Text) & "','" & Trim$(txtVendor (5).Text) & "','" & Trim$(txtVendor (6).Text) & "','" & Trim$(txtVendor (7).Text) & "','" & Trim$(txtVendor (8).Text) & "','" & Trim$(txtVendor (0).Text) & "','" & Trim$(txtVendor (9).Text) & "','" & Trim$(txtVendor (10).Text) & "','" & Trim$(txtVendor (11).Text) & "','" & Trim$(txtVendor (12).Text) & "','" & Trim$(txtVendor (13).Text) & "','" & Trim$(txtVendor (14).Text) & "')", Conn, 3, 3
        [/code]

        I think you've forgot to insert '.

        Good Luck : )

        Comment

        • creative1
          Contributor
          • Sep 2007
          • 274

          #5
          Hi Guys
          Lotus18 is right Recordset.Open works for insert statement too.
          I used the query that Lotus18 wrote in his post but noluck same error message.

          P.S Extension is a numeric field sstored in txtVendot(0).te xt

          If I don't use it with no error and complete transection, If I add this field I get following error when it reach the query:
          Run time error SYNYAX ERROR in InsertInto statement. I realy don't whats wrong with this statement.


          regards

          Comment

          • Mohan Krishna
            New Member
            • Oct 2007
            • 115

            #6
            Originally posted by creative1
            Hi Guys
            :
            :
            P.S Extension is a numeric field sstored in txtVendot(0).te xt
            :
            Run time error SYNYAX ERROR in InsertInto statement. I realy don't whats wrong with this statement.
            Hi Creative1 !
            May I give a suggestion to my knowledge...
            Can't we use VAL ( TRIM ( ... ) ) or INT ( TRIM (...) ) for that numeric field and instead of TRIM$ ?
            Don't think otherwise if there is mistake in my suggestion!
            ThanQ! ALL THE BEST!

            Comment

            • creative1
              Contributor
              • Sep 2007
              • 274

              #7
              Waooo! your tip worked I used
              " & Val(Trim$(txtVe ndor(0).Text)) & "
              and it worked .
              thanks alot

              Comment

              • lotus18
                Contributor
                • Nov 2007
                • 865

                #8
                Originally posted by creative1
                Waooo! your tip worked I used
                " & Val(Trim$(txtVe ndor(0).Text)) & "
                and it worked .
                thanks alot
                So for the next time you need to show us much more details. : )

                ALL THE BEST MOHAN!!!

                Comment

                Working...