+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    02-26-2009
    Location
    U.S
    MS-Off Ver
    Excel 2003
    Posts
    42

    Getting Error in text data type

    Hello everyone,

    Not getting text data types.

    I have use this code :

    Code:
    Private Sub Command6_Click()
    Dim ssql As String
    ssql = "insert into table1(name,rollno,reason) values('" & Text0.Value & "'," & Text2.Value & ",'" & Text4.Value & "')"
    DoCmd.RunSQL ssql
    End Sub
    Can anyone solve this problem

  2. #2
    Registered User
    Join Date
    03-20-2008
    Location
    Buffalo, NY USA
    Posts
    43

    Re: Getting Error in text data type

    try this:

    Code:
    ssql = "INSERT INTO Table1 ( name, rollno, reason )" & _
            " SELECT '" & Me.text0.value & "' AS Expr1, '" & Me.text2.value & "' AS Expr2, '" & Me.text4.value & "' AS Expr3;"
    Also, I prefaced the field references with "Me", assuming the button is on the same form where the fields are.

  3. #3
    Registered User
    Join Date
    02-26-2009
    Location
    U.S
    MS-Off Ver
    Excel 2003
    Posts
    42

    Re: Getting Error in text data type

    Hi,

    Thanks for your reply this code works perfectly.

    Thanks once again.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0