Import to Word 2002

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
 
P

Piet Linden

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
 
J

johnb

Hi Piet

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

john
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top