Reputation: 446
I am trying to import fields from a form field word document I have created into a MS-Access table. The import works fine unless there is a null in one of the date fields, and then it throws a type mismatch error. How do I keep from getting this error?
Dim rst As New ADODB.Recordset
With rst
.AddNew
!BPRid = doc.FormFields("frmBPRid").Result
If Not IsNull(doc.FormFields("frmReceiptDate").Result) Then
!ReceiptDate = doc.FormFields("frmReceiptDate").Result
End If
.Update
.Close
End With
I tried wrapping it in an if statement as seen above, but it seems it doesn't recognize the field as null. Any help would be appreciated. Thanks in Advance.
Upvotes: 2
Views: 768
Reputation: 91366
I suspect it is probably a zero length string ("").
You might like to use IsDate.
If IsDate(doc.FormFields("frmReceiptDate").Result) Then
!ReceiptDate = doc.FormFields("frmReceiptDate").Result
End If
For other data types, you can check for a zero length string and space filled fields like so:
If Trim(doc.FormFields("frmReceiptDate").Result & "") <> vbNullString
Upvotes: 3