A
A_Classic_Man
I have built a MS Word 97 form that sends data in the bookmarks to a
table in Access 97 when I click a command button on the Word form.
With the help of Robert Morley, Thanks Rob, I am able to get the data
into the Access table. The problem is that if a bookmark is a Date/
Time or Number and contains no data, I get the run time error 13 "Type
Mismatch" message. If the bookmarks contain data or is a text field,
the data fills the Access table fields just fine. I have placed data
in all of the bookmarks and everything works.
What code do I need to add to get this working
I'm also wondering if the same thing will happen with the text
bookmarks that have no data.
Many thanks to all of you guys and gals who so freely contribute your
knowledge to help people like me who know just enough to be dangerous.
Your help has gotten me out of many a jam.
Ron
Here's the code
Private Sub cmdSendToAccess_Click()
Dim strfldPerAssign As String '(Text field)
Dim strfldAccNum As Long '(Text field)
Dim strfldEventNum As String '(Text field-contains numbers and
letters)
Dim strfldEventDate As Date '(Date/Time field)
Dim strfldReqDate As Date '(Date/Time field)
Dim strfldCompleted As String '(Text field)
Dim strfldApp1 As String '(Text field)
Dim strfldApp1Shift As String '(Text field)
Dim strfldStartTime1 As Date '(Date/Time field)
Dim strfldEndTime1 As Date '(Date/Time field)
Dim strfldTotalTime1 As Date '(Date/Time field)
Set ThisDoc = ActiveDocument
strfldPerAssign = ThisDoc.FormFields("fldPerAssign").Result
strfldAccNum = ThisDoc.FormFields("fldAccNum").Result
strfldEventNum = ThisDoc.FormFields("fldEventNum").Result
strfldEventDate = ThisDoc.FormFields("fldEventDate").Result
strfldReqDate = ThisDoc.FormFields("fldReqDate").Result
strfldCompleted = ThisDoc.FormFields("fldCompleted").Result
strfldApp1 = ThisDoc.FormFields("fldApp1").Result
strfldApp1Shift = ThisDoc.FormFields("fldApp1Shift").Result
strfldStartTime1 = ThisDoc.FormFields("fldStartTime1").Result
strfldEndTime1 = ThisDoc.FormFields("fldEndTime1").Result
strfldTotalTime1 = ThisDoc.FormFields("fldTotalTime1").Result
Set wrkjet = CreateWorkspace("", "admin", "", dbUseJet)
Set MyDB = wrkjet.OpenDatabase("E:\App\WorkCompleted")
Set MyTbl = MyDB.OpenRecordset("JobAssignments")
With MyTbl
.AddNew
!PerAssign = strfldPerAssign
!accNum = CLng(strfldAccNum)
!EventNum = strfldEventNum
!EventDate = CDate(strfldEventDate)
!ReqDate = CDate(strfldReqDate)
!Completed = strfldCompleted
!App1 = strfldApp1
!App1Shift = strfldApp1Shift
!StartTime1 = CDate(strfldStartTime1)
!EndTime1 = CDate(strfldEndTime1)
!TotalTime1 = CDate(strfldTotalTime1)
.Update
End With
Set MyTbl = Nothing
Set MyDB = Nothing
Set wrkjet = Nothing
End Sub
table in Access 97 when I click a command button on the Word form.
With the help of Robert Morley, Thanks Rob, I am able to get the data
into the Access table. The problem is that if a bookmark is a Date/
Time or Number and contains no data, I get the run time error 13 "Type
Mismatch" message. If the bookmarks contain data or is a text field,
the data fills the Access table fields just fine. I have placed data
in all of the bookmarks and everything works.
What code do I need to add to get this working
I'm also wondering if the same thing will happen with the text
bookmarks that have no data.
Many thanks to all of you guys and gals who so freely contribute your
knowledge to help people like me who know just enough to be dangerous.
Your help has gotten me out of many a jam.
Ron
Here's the code
Private Sub cmdSendToAccess_Click()
Dim strfldPerAssign As String '(Text field)
Dim strfldAccNum As Long '(Text field)
Dim strfldEventNum As String '(Text field-contains numbers and
letters)
Dim strfldEventDate As Date '(Date/Time field)
Dim strfldReqDate As Date '(Date/Time field)
Dim strfldCompleted As String '(Text field)
Dim strfldApp1 As String '(Text field)
Dim strfldApp1Shift As String '(Text field)
Dim strfldStartTime1 As Date '(Date/Time field)
Dim strfldEndTime1 As Date '(Date/Time field)
Dim strfldTotalTime1 As Date '(Date/Time field)
Set ThisDoc = ActiveDocument
strfldPerAssign = ThisDoc.FormFields("fldPerAssign").Result
strfldAccNum = ThisDoc.FormFields("fldAccNum").Result
strfldEventNum = ThisDoc.FormFields("fldEventNum").Result
strfldEventDate = ThisDoc.FormFields("fldEventDate").Result
strfldReqDate = ThisDoc.FormFields("fldReqDate").Result
strfldCompleted = ThisDoc.FormFields("fldCompleted").Result
strfldApp1 = ThisDoc.FormFields("fldApp1").Result
strfldApp1Shift = ThisDoc.FormFields("fldApp1Shift").Result
strfldStartTime1 = ThisDoc.FormFields("fldStartTime1").Result
strfldEndTime1 = ThisDoc.FormFields("fldEndTime1").Result
strfldTotalTime1 = ThisDoc.FormFields("fldTotalTime1").Result
Set wrkjet = CreateWorkspace("", "admin", "", dbUseJet)
Set MyDB = wrkjet.OpenDatabase("E:\App\WorkCompleted")
Set MyTbl = MyDB.OpenRecordset("JobAssignments")
With MyTbl
.AddNew
!PerAssign = strfldPerAssign
!accNum = CLng(strfldAccNum)
!EventNum = strfldEventNum
!EventDate = CDate(strfldEventDate)
!ReqDate = CDate(strfldReqDate)
!Completed = strfldCompleted
!App1 = strfldApp1
!App1Shift = strfldApp1Shift
!StartTime1 = CDate(strfldStartTime1)
!EndTime1 = CDate(strfldEndTime1)
!TotalTime1 = CDate(strfldTotalTime1)
.Update
End With
Set MyTbl = Nothing
Set MyDB = Nothing
Set wrkjet = Nothing
End Sub