如何使用DAO传递LONGTEXT参数?

时间:2019-04-17 07:35:28

标签: sql excel vba ms-access

我想通过参数将超过255个字符的用户窗体文本框传递给MS Access字段。给定文本框中的字符长度,我将无法执行此操作,这会生成运行时错误。我想避免直接在宏中编写SQL语句。不使用ADO可以解决此限制吗?

代码

Sub updateRecord()

Dim db As Database
Dim qdf As QueryDef


Application.StatusBar = "Connecting to PBS Database......"
Set db = OpenDatabase("Z:\UBPB CRM Project\pbsbackup.mdb")
Set qdf = db.QueryDefs("addclient")


Application.CalculateUntilAsyncQueriesDone

Application.StatusBar = "Uploading Client Data to PBS server...."
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False

    qdf!pbsbranch = Sheet4.Range("A2")
    qdf!pbsclient = addnewClient.client
    qdf!pbspriority = addnewClient.priority_
    qdf!pbssource = addnewClient.priority
    qdf!pbscontact = addnewClient.contact
    qdf!pbsresult = addnewClient.result
    qdf!pbsnextsteps = addnewClient.segmentType
    qdf!pbsattempts = addnewClient.Label11
    qdf!pbsnotes = addnewClient.notes


qdf.Execute dbFailOnError


qdf.Close
db.Close
Application.StatusBar = "Upload Successful!"

Set qdf = Nothing
Set db = Nothing

Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub

0 个答案:

没有答案