技術(shù) 點(diǎn)
- 技術(shù)
- 點(diǎn)
- V幣
- 點(diǎn)
- 積分
- 5960
|
3#
發(fā)表于 2002-11-27 00:16:00
|
只看該作者
如何解決“非法引用null"值的錯(cuò)誤
我做了一個(gè)小程序,準(zhǔn)備向WORD的表中填加數(shù)據(jù)庫中的字段值,但是出現(xiàn)了一個(gè)小問題,當(dāng)字有數(shù)據(jù)時(shí),沒有問題,但是當(dāng)沒有數(shù)據(jù)是提示我“非法引用NULL值”,我應(yīng)該如何處理,就象郵件合并是,沒數(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
做以下的修改:
.Cell(1, 2).Range.Text = "" & rst("01")
.Cell(1, 2).FitText = True
.Cell(1, 4).Range.Text = "" & rst("02")
因?yàn)?quot;"與Null值連接時(shí)值為"","" 與其它值連接時(shí)值不變.
這可是我的妙招呵!
|
|