1

错误提示“该字段太小,无法接受您尝试添加的数据量。请尝试插入或粘贴更少的数据。”

数据库应该从传递给它的 Excel 工作表中提取信息,并将信息导入到文本字段的记录集中。但是,文本字段(位于该行的某处)被限制为 50 个字符。如何更改文本字段的最大大小?感谢您的任何帮助

这只是代码的一部分,我试图放大的文本字段是“Idea_#”,这是我发布的代码的最后一行

Sub Read_Recommendations() On Error GoTo error_code Dim FD As Office.FileDialog Dim xlapp As Excel.Application Dim xlsheet As Excel.Worksheet Dim xlbook As Excel.Workbook

Dim db As Database
Dim rs As Recordset
Dim sql As String

Dim WP As String
Dim row As Integer

Dim File As String
Set db = CurrentDb

Set FD = Application.FileDialog(msoFileDialogOpen)
If FD.Show = True Then
    File = FD.SelectedItems(1)
    Set xlapp = CreateObject("Excel.Application")
    Set xlbook = GetObject(File)
    Set xlsheet = xlbook.Worksheets("Recommendation Approval Form")

    Dim protection As Boolean
    With xlsheet

        'support unprotected worksheets
        protection = xlsheet.ProtectContents
        If protection Then xlsheet.Unprotect "veproject"

        WP = .Range("WP_Number")
        ' Check that active WP and the WP of the uploading form is the same
        ' If WPs are different, awares users and prompts user whether or not to continue
        Dim DifferentProject As String
        If Not get_WP = WP Then
            DifferentProject = MsgBox("You are uploading to the project with WP number: " & WP & " which is not the active project. Do you wish to continue?", vbYesNo)
            If DifferentProject = 7 Then Exit Sub
        End If

        ' Check that WP is correct by checking if it exists in the Record Information table

        ' delete the existing recomendations, we want to keep the most recent recomendations
        ' perhaps change this to a dialog in the future
        sql = "DELETE * from tbl_recomendations WHERE WP_Number = '" & WP & "'"

        db.Execute (sql)
        row = 8

        Set rs = db.OpenRecordset("tbl_recomendations")
        Do While .Range("D" & row) <> ""
            rs.AddNew
            rs("WP_Number") = WP
            rs("Idea_#") = (.Range("C" & row))

...........

4

1 回答 1

2

在 Access 中,tbl_recomendations在设计视图中打开。听起来Field Size属性Idea_#设置为 50。您最多可以将其更改为 255。

如果您需要存储超过 255 个字符,请将Idea_#数据类型Text更改为Memo

于 2013-09-24T21:47:19.827 回答