技術(shù) 點(diǎn)
- 技術(shù)
- 點(diǎn)
- V幣
- 點(diǎn)
- 積分
- 117
|
3#

樓主 |
發(fā)表于 2002-11-25 22:34:00
|
只看該作者
對(duì)不起
對(duì)不起,我寫(xiě)的一個(gè)回復(fù)貼子,發(fā)錯(cuò)了,請(qǐng)幫我一下這個(gè)錯(cuò)誤行嗎???
如何解決“非法引用null"值的錯(cuò)誤
我做了一個(gè)小程序,準(zhǔn)備向WORD的表中填加數(shù)據(jù)庫(kù)中的字段值,但是出現(xiàn)了一個(gè)小問(wèn)題,當(dāng)字有數(shù)據(jù)時(shí),沒(méi)有問(wèn)題,但是當(dāng)沒(méi)有數(shù)據(jù)是提示我“非法引用NULL值”,我應(yīng)該如何處理,就象郵件合并是,沒(méi)數(shù)據(jù),只顯示為空的單元格。因?yàn)樽侄魏芏,不能每個(gè)都去判斷是否為NULL
Sub startword()
On Error GoTo err_startword
Dim wrd As New Word.Application, isrunning As Boolean
Dim tableNew As Table, tableNew1 As Table
Dim dbMyDB As Database, rst As Recordset, rst1 As Recordset
isrunning = True
wrd.Documents.Open fileName:="D:\Documents and Settings\ysc\My Documents\djb"
wrd.Visible = True
Set tableNew = ActiveDocument.Tables(1)
Set dbMyDB = CurrentDb
Set rst = dbMyDB.OpenRecordset("jijan1", dbOpenSnapshot)
rst.MoveFirst
With tableNew
.Cell(1, 2).Range.Text = rst("01")
.Cell(1, 2).FitText = True
.Cell(1, 4).Range.Text = rst("02")
End With
If isrunning = False Then
wrd.Quit
End If
Exit Sub
err_startword:
If Err.Number = 429 Then
Set wrd = CreateObject("word.application")
isrunning = True
Resume Next
Else
MsgBox Err.Number & "" & Err.Description
Exit Sub
End If
End Sub
|
|