aaronram
07-07-2011, 03:22 PM
I have an Word form with 400+ bookmarked check boxes. I need to keep track as to which check box is checked, but do not care if the box is not checked. I tried to keep track of each check box individually, but ran into the 255 field limit. Since experience shows that there is a maximum of 50 checked boxes in any one form, is there a way to have Access populate the next field in the table with a set value corresponding to the box that was checked? That is, if the first checked box in the Word form is labeled "UNS56", with 56 identifying which box number it is, I want Access to make field "Box1" have a value of "192.5" (the value is a unique reference to an internal statute) . Then if the second checked box is "UNS102", field "Box2" should have a value of "191.36" and so on. If it makes any difference, each of the 400+ questions have multiple options available, but I am only concerned if one particular option is picked.
Below is a shortened version of my code that imported the individual records:
Sub GetWordData()
Dim appWord As Word.Application
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim strDocName As String
Dim blnQuitWord As Boolean
Dim file As String
Dim dfol As String
file = InputBox("Enter the name of form" & _
"you want to import", "Import Form")
strDocName = "C:\Documents and Settings\aaronr\Desktop\Form\SampleForms\" & file
Set appWord = GetObject(, "Word.Application")
Set doc = appWord.Documents.Open(strDocName)
cnn.Open "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=C:\Documents and Settings\aaronr\Desktop\Form\Form1.accdb;"
rst.Open "tblForms", cnn, _
adOpenKeyset, adLockOptimistic
With rst
.AddNew
!OPID = doc.FormFields("OPID").Result
!OPName = doc.FormFields("OPname").Result
!InspDate = doc.FormFields("Date").Result
!UNS1 = doc.FormFields("UNS1").Result
!UNS2 = doc.FormFields("UNS2").Result
!UNS3 = doc.FormFields("UNS3").Result
!UNS4 = doc.FormFields("UNS4").Result
!UNS5 = doc.FormFields("UNS5").Result
!UNS6 = doc.FormFields("UNS6").Result
.Update
.Close
End With
doc.Close
If blnQuitWord Then appWord.Quit
cnn.Close
dfol = "C:\Documents and Settings\aaronr\Desktop\Form\SampleForms\Imported\" & file
Name strDocName As dfol
MsgBox "Form Imported!"
Cleanup:
Set rst = Nothing
Set cnn = Nothing
Set doc = Nothing
Set appWord = Nothing
End Sub
Thank you
Below is a shortened version of my code that imported the individual records:
Sub GetWordData()
Dim appWord As Word.Application
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim strDocName As String
Dim blnQuitWord As Boolean
Dim file As String
Dim dfol As String
file = InputBox("Enter the name of form" & _
"you want to import", "Import Form")
strDocName = "C:\Documents and Settings\aaronr\Desktop\Form\SampleForms\" & file
Set appWord = GetObject(, "Word.Application")
Set doc = appWord.Documents.Open(strDocName)
cnn.Open "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=C:\Documents and Settings\aaronr\Desktop\Form\Form1.accdb;"
rst.Open "tblForms", cnn, _
adOpenKeyset, adLockOptimistic
With rst
.AddNew
!OPID = doc.FormFields("OPID").Result
!OPName = doc.FormFields("OPname").Result
!InspDate = doc.FormFields("Date").Result
!UNS1 = doc.FormFields("UNS1").Result
!UNS2 = doc.FormFields("UNS2").Result
!UNS3 = doc.FormFields("UNS3").Result
!UNS4 = doc.FormFields("UNS4").Result
!UNS5 = doc.FormFields("UNS5").Result
!UNS6 = doc.FormFields("UNS6").Result
.Update
.Close
End With
doc.Close
If blnQuitWord Then appWord.Quit
cnn.Close
dfol = "C:\Documents and Settings\aaronr\Desktop\Form\SampleForms\Imported\" & file
Name strDocName As dfol
MsgBox "Form Imported!"
Cleanup:
Set rst = Nothing
Set cnn = Nothing
Set doc = Nothing
Set appWord = Nothing
End Sub
Thank you