Opening Microsoft Word

drusteeby

Registered User.
Local time
Today, 14:48
Joined
Jul 9, 2009
Messages
29
This is the code i have right now:

'Select the bookmark setup in the template
.ActiveDocument.Bookmarks("text2").Select
'Populate the bookmark with this data
.Selection.Text = (CStr(Forms!Form1!cmboHullNGSS))

And I have this for about 30 different forms, I have it open a certian document in Word and it populates the bookmark that i specify with whatever is in the form field that I specify.

The problem is that if I leave a form field blank it give me an error like "improper use of Null" and it quits executing the code, so it fills in everything before that form field but not the ones after. What is the proper way to make the code "skip" that form field if It is null?


Thanks
 
You need to trap this error (err.number 94 - Invalid use of Null)

Use an On Error statement to trap it and perform a resume next.

David
 
What is the synatx for that? I am new to SQL

thanks
 
At the beginning of your code enter

On Error Goto eTrap





At the end of your code

eTrap:
If Err.Number = 94 Then
Resume Next
End If

Alternatively if you wrap Nz() around your incoming values it should not error

.Selection.Text = Nz(CStr(Forms!Form1!cmboHullNGSS),"")

Or

.Selection.Text = Trim(CStr(Forms!Form1!cmboHullNGSS) & " ")

David
 

Users who are viewing this thread

Back
Top Bottom