Import Word Form Data Issue

smbarney

Registered User.
Local time
Today, 17:56
Joined
Jun 7, 2006
Messages
60
I am using the follow code to import data from a Word form into my MS Access 2010 DB:

Code:
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tmpSIRs", dbOpenDynaset)

With rst
    .AddNew
    
'Incident Date/Time
    ![sirIncidentDate] = Format(doc.FormFields("sirIncidentDate").Result, "Medium Date")
    ![sirIncidentTime] = Format(doc.FormFields("sirIncidentTime").Result, "Short Time")
    
'Incident Location
    ![locRegion] = doc.FormFields("locRegion").Result
    ![locOffice] = doc.FormFields("locOffice").Result

'Submitter Information
    ![sirSubmitterEmail] = doc.FormFields("sirSubmitterEmail").Result
    ![sirSubmitterFirstNam] = doc.FormFields("sirSubmitterFirstNam").Result
    ![sirSubmitterLastName] = doc.FormFields("sirSubmitterLastName").Result
    ![sirSubmitterTelephon] = tSirSubmitterTelephone
    
'EMS Information
    ![emsContacted] = doc.FormFields("emsContacted").Result
    ![emsFormSubmited] = doc.FormFields("emsFormSubmited").Result
    ![emsLocation] = doc.FormFields("emsLocation").Result
    ![emsTransported] = doc.FormFields("emsTransported").Result
    ![emsType] = doc.FormFields("emsType").Result

'Property Information
    ![PropertyLocation] = doc.FormFields("PropertyLocation").Result
    ![PropertyQuantity] = doc.FormFields("PropertyQuantity").Result
    ![PropertyReportNumber] = doc.FormFields("PropertyReportNumber").Result
    ![PropertySN] = doc.FormFields("PropertySN").Result
    ![PropertyType] = doc.FormFields("PropertyType").Result



![Notification] = doc.FormFields("Notification").Result
![SirNumber] = doc.FormFields("SirNumber").Result

![ReportDate] = Format(doc.FormFields("ReportDate").Result, "Medium Date")
![ReportedBy] = UCase(doc.FormFields("ReportedBy").Result)
![ReportTime] = Format(doc.FormFields("ReportTime").Result, "Short Time")

.Update

Everything works great except for two fields:
![emsContacted] = doc.FormFields("emsContacted").Result
![emsTransported] = doc.FormFields("emsTransported").Result

On the Word Form, these two fields are drop-downs with three options: blank, No, and Yes. If the users leaves them blank, then Access ignores them--which is what I want. However, if the user says yes or no, Access puts a "-1" in the database. Both the Word form and Access field are text.

I can't figure this one out. I don't get any error messages. Were does the -1 come from? It is really causing problems.

Help. Thanks
 
I take that the emsContacted and emsTransported's Data Type are set to Yes/No.. In Access the Data Type for Yes/No type can take three values..

  • Yes Or No
  • -1 Or 0
  • True Or False
By translation it will be -1 or 0.. If there is nothing Null (the third state) will be assumed.. Makes sense?
 
No, they are both just text fields. The tmpSIRs table is temporary table I use to pull the data into before I insert it into the primary table. As such, I just pull the text.

One correction to my post, the "-1" only happens when the user selects "Yes" on the Word Form. If they select "No", Access imports "No" into the tmpSIRs table as it should.

How strange is this?
 

Users who are viewing this thread

Back
Top Bottom