Hi,
A fairly simple (I think) question:
I have a form, with a button on it that opens a word document and fills in some (bookmark) fields on it. That all works nicely. The problem is, I am attempting to get certain bookmarks filled in with information from different db fields depending on the information stored in certain fields. More specifically:
The database is opened, an SQL statement is created, and the recordset is created as such....
Set rsMidbase1 = dbMidbase.OpenRecordset(sSql)
' [in the recordset, a field called "Add2" exists.]
' this is now the bit that doesn't work:
If rsMidbase1![Add2] = "Null" Then
objDoc.Bookmarks("Add2"
.Range.text = rsMidbase1![Suburb] & " " & rsMidbase1![State] & " " & rsMidbase1![Country] & " " & rsMidbase1![PCode]
Else
objDoc.Bookmarks("Add2"
.Range.text = rsMidbase1![Add2]
objDoc.Bookmarks("Add3"
.Range.text = rsMidbase1![Suburb] & " " & rsMidbase1![State] & " " & rsMidbase1![Country] & " " & rsMidbase1![PCode]
End If
The intention is: if the "Add2" Field has 'stuff', then to fill it into the "Add2" bookmark, and put the "Add3" field information into the "Add3" bookmark. This works fine.
If the "Add2" Field is Null, then the "Add3" field information (which will never be null) should be put in the "Add2" bookmark, and the "Add3" bookmark left blank. The problem is: in a case where the "Add2" field is null, the "Else" Branch of the If statement is still exectued, and on the first line of it,
----> Run-time error '94': Invalid use of null.
error message occurs.
Is the rsMidbase1![Add2] = "Null" bit not doing as I plan?
Please help. [sig][/sig]
A fairly simple (I think) question:
I have a form, with a button on it that opens a word document and fills in some (bookmark) fields on it. That all works nicely. The problem is, I am attempting to get certain bookmarks filled in with information from different db fields depending on the information stored in certain fields. More specifically:
The database is opened, an SQL statement is created, and the recordset is created as such....
Set rsMidbase1 = dbMidbase.OpenRecordset(sSql)
' [in the recordset, a field called "Add2" exists.]
' this is now the bit that doesn't work:
If rsMidbase1![Add2] = "Null" Then
objDoc.Bookmarks("Add2"
Else
objDoc.Bookmarks("Add2"
objDoc.Bookmarks("Add3"
End If
The intention is: if the "Add2" Field has 'stuff', then to fill it into the "Add2" bookmark, and put the "Add3" field information into the "Add3" bookmark. This works fine.
If the "Add2" Field is Null, then the "Add3" field information (which will never be null) should be put in the "Add2" bookmark, and the "Add3" bookmark left blank. The problem is: in a case where the "Add2" field is null, the "Else" Branch of the If statement is still exectued, and on the first line of it,
----> Run-time error '94': Invalid use of null.
error message occurs.
Is the rsMidbase1![Add2] = "Null" bit not doing as I plan?
Please help. [sig][/sig]