L
lula
hi to all.... I'm adding in a form some computer repair requests from a word
document. I have a button, that when I click on it, it grabs the info from
the word document and adds it into my database. the thing is that I have to
go out of the form and open it up again to see my new record.
I tried Me.requery
docmd.requery ("name of my form") but it's not working....
I'm not sure where I have to put it, so here is a little bit of my code and
if you can tell me exactly what to put and where, I would be very greatful.
Dim oDoc As Object 'Word.Document
Dim strEmployeeName As String
Dim strSiteName As String
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
'Open the document in an instance of Word
Set oDoc = GetObject("C:\ComputerRepair3.doc")
'Get the contents of the formfields
strEmployeeName = oDoc.formfields("Text7").result
strSiteName = oDoc.formfields("Dropdown4").result
'Close the document without saving
oDoc.Close False
'appending the new record to the table
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\"Inventory.mdb;"
rst.Open "CRR Test", cnn, _
adOpenKeyset, adLockOptimistic
With rst
.AddNew
!employee = strEmployeeName
!site = strSiteName
.Update
.Close
End With
If blnQuitWord Then appWord.Quit
cnn.Close
MsgBox "CRR Imported!"
Cleanup:
Set rst = Nothing
Set cnn = Nothing
Set oDoc = Nothing
Exit Sub
End Sub
thank you very much for your answer in advance.
document. I have a button, that when I click on it, it grabs the info from
the word document and adds it into my database. the thing is that I have to
go out of the form and open it up again to see my new record.
I tried Me.requery
docmd.requery ("name of my form") but it's not working....
I'm not sure where I have to put it, so here is a little bit of my code and
if you can tell me exactly what to put and where, I would be very greatful.
Dim oDoc As Object 'Word.Document
Dim strEmployeeName As String
Dim strSiteName As String
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
'Open the document in an instance of Word
Set oDoc = GetObject("C:\ComputerRepair3.doc")
'Get the contents of the formfields
strEmployeeName = oDoc.formfields("Text7").result
strSiteName = oDoc.formfields("Dropdown4").result
'Close the document without saving
oDoc.Close False
'appending the new record to the table
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\"Inventory.mdb;"
rst.Open "CRR Test", cnn, _
adOpenKeyset, adLockOptimistic
With rst
.AddNew
!employee = strEmployeeName
!site = strSiteName
.Update
.Close
End With
If blnQuitWord Then appWord.Quit
cnn.Close
MsgBox "CRR Imported!"
Cleanup:
Set rst = Nothing
Set cnn = Nothing
Set oDoc = Nothing
Exit Sub
End Sub
thank you very much for your answer in advance.