在access中text字段只允许255个字符,而memo型可允许64000。但是,在下例语句中,vb却报错,说字段类型不对!请各位帮忙参详一下!!public sub CreateTable()Dim TableName As String
    Dim strSql2 As String
    Dim dbconnection As New ADODB.Connection
    
GetTableName:
    TableName = InputBox("请输入表名称(尽量使用英文字母):", "导出提示")
    
    dbpath = App.Path & "/customer.mdb"
    
    If dbconnection.State = adStateClosed Then
        dbconnection.Open "provider=microsoft.jet.oledb.4.0;data source=" & dbpath
    End If
    
    
    If TableExists(dbconnection, TableName) Then
        If MsgBox("该表已存在,请输入新的表名!", vbYesNo, "出错提示") Then
            GoTo GetTableName
        Else
            dbconnection.Close
            Exit Sub
        End If
    End If
    strSql = "create table " & TableName & " ( " & vbCrLf & _
            "customname text(200)," & vbCrLf & _
            "customaddress text(200), " & vbCrLf & _
            "postnum text(10), " & vbCrLf & _
            "linkman text(20), " & vbCrLf & _
            "tel text(50), " & vbCrLf & _
            "fax text(50), " & vbCrLf & _
            "customtype text(20), " & vbCrLf & _
            "explain text(255) )"
    
    dbconnection.Execute strSqlend sub

解决方案 »

  1.   

    你的create table语句中为什么要加vbCrLf?
      

  2.   

    你这语句时也没有MEMO的类型啊,并且我执行没报错误!!??
      

  3.   

    to cuizm:不好意思,拷错了部分,最后应该是"explain memo(500)"。
    to victorycyz:我是将整个存储过程放在变量strsql中的,所以要用 vbcrlf
      

  4.   

    vbcrlf可省略。memo没有限制大小的属性。
      

  5.   

    就是说,可改成"explain memo"就行。
      

  6.   

    memo字段不能指定大小strSql = "create table " & TableName & " ( " & vbCrLf & _
                "customname text(200)," & vbCrLf & _
                "customaddress text(200), " & vbCrLf & _
                "postnum text(10), " & vbCrLf & _
                "linkman text(20), " & vbCrLf & _
                "tel text(50), " & vbCrLf & _
                "fax text(50), " & vbCrLf & _
                "customtype text(20), " & vbCrLf & _
                "explain memo )"
        
        dbconnection.Execute strSql
      

  7.   

    to cuizm:如果指定memo大小时,使用sql语句向表中添加数据时,会报错:“字段太小而不能接受所添加的数据的数量”