Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I'm a freelance consultant, and your site's helped me with many issues. I just wanted you to know that someone does appreciate the intelligent help your site offers."

Geography

Where in the world do Tek-Tips members come from?
Earth (TechnicalUser)
13 Sep 00 1:23
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.
kctaylordotcodotuk (Programmer)
13 Sep 00 4:30
If isnull(rsMidbase1![Add2]) Then

or

If Len(rsMidbase1![Add2] & "") = 0 Then

Keith C Taylor
TekTips@kctaylor.co.uk
The Information Gardener
The C stands for Computer!

Earth (TechnicalUser)
14 Sep 00 0:59
That worked perfectly. Thanks Keith.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close