Import to Word 2002

  • Thread starter Thread starter johnb
  • Start date Start date
J

johnb

Hi All
I have a Word form that I import to Access when it's filled in. I've a
procedure in Access VBA then read the form and It works fine. But now I need
to modify the form and add a another field. So I will have 2 versions of the
same form in use. When I import the newer version it causes an error.

Do I catch the error and resume next or should I have an IF (or
something)statement at the point where vba reads the word form where the new
field is located? I think the latter is better but how do I code?

the code snippet I'm using is....
with rec
.addnew
!CateCat = (doc.FormFields("FieldName").result

.close
end with

I hope this makes sense

johnb
 
Hi All
I have a Word form that I import to Access when it's filled in. I've a
procedure in Access VBA then read the form and It works fine. But now I need
to modify the form and add a another field. So I will have 2 versions of the
same form in use. When I import the newer version it causes an error.

Do I catch the error and resume next or should I have an IF (or
something)statement at the point where vba reads the word form where the new
field is located? I think the latter is better but how do I code?

the code snippet  I'm using is....
with rec
  .addnew
  !CateCat = (doc.FormFields("FieldName").result

  .close
end with

I hope this makes sense

johnb

You could write a function to determine if the form field exists (if
you try to reference a form field that doesn't exist, Access will
raise an error.) So if Err.Number = 0, the field exists, and if it's
something other than that, the field does not exist. So your code
might look something like:

with rec
.AddNew
If fFormFieldExists(strFieldName) Then
!CateCat = doc.FormFields("FieldName").result
End If
.Update
End With
 
Hi Piet

The "FormFieldExits" is not recognised on my machine. But "FormField" works.
Am I missing something?

john
 
Back
Top