Discussion:
Add/Update a Record in VB
(too old to reply)
Donald Fisher
2007-08-25 23:23:27 UTC
Permalink
I have an Access database as a data source and would like to add a
record using the following code:

Dim ol002 As New Microsoft.Office.Interop.Outlook.Application
Dim olns002 As Microsoft.Office.Interop.Outlook.NameSpace
Dim strENTRYID, strSTOREID, strFOLDER, strSECTION
olns002 = ol002.GetNamespace("MAPI")
Dim fldFolder As Microsoft.Office.Interop.Outlook.MAPIFolder
fldFolder = ol002.GetNamespace("MAPI").PickFolder
strENTRYID = fldFolder.EntryID
strSTOREID = fldFolder.StoreID
strSECTION = InputBox("Enter the section name as you would like
it to be displayed in the schedule [ALL CAPS]." & Chr(13) & Chr(13) & _
"Ensure this is the same name for a section already
loaded.", " Enter Section -")
strFOLDER = InputBox("Enter the exact name of the folder on
your public share for this section [ALL CAPS].", " Enter Share Name -")

Me._Outlook_Task_Reporting_Tool_1_0_2003DataSet.tblSections.AddtblSectionsRow(strSECTION,
strFOLDER, strENTRYID, strSTOREID).AcceptChanges()
MsgBox("The following data has been added to 'tblSections':" &
Chr(13) & Chr(13) & "SECTION: " & strSECTION & Chr(13) & Chr(13) &
"SHARE: " & _
strFOLDER & Chr(13) & Chr(13) & "ENTRYID: " & strENTRYID &
Chr(13) & Chr(13) & "STOREID: " & strSTOREID, MsgBoxStyle.OkOnly, " Add
Complete -")


Why doesn't it work? I get no errors but the backend table is not
updated for some reason.
Scott M.
2007-08-26 17:03:02 UTC
Permalink
There is absolutely no code below that has anything to do with Access.
Perhaps this is why your Acees table is not getting updated?
I have an Access database as a data source and would like to add a record
Dim ol002 As New Microsoft.Office.Interop.Outlook.Application
Dim olns002 As Microsoft.Office.Interop.Outlook.NameSpace
Dim strENTRYID, strSTOREID, strFOLDER, strSECTION
olns002 = ol002.GetNamespace("MAPI")
Dim fldFolder As Microsoft.Office.Interop.Outlook.MAPIFolder
fldFolder = ol002.GetNamespace("MAPI").PickFolder
strENTRYID = fldFolder.EntryID
strSTOREID = fldFolder.StoreID
strSECTION = InputBox("Enter the section name as you would like it
to be displayed in the schedule [ALL CAPS]." & Chr(13) & Chr(13) & _
"Ensure this is the same name for a section already loaded.",
" Enter Section -")
strFOLDER = InputBox("Enter the exact name of the folder on your
public share for this section [ALL CAPS].", " Enter Share Name -")
Me._Outlook_Task_Reporting_Tool_1_0_2003DataSet.tblSections.AddtblSectionsRow(strSECTION,
strFOLDER, strENTRYID, strSTOREID).AcceptChanges()
MsgBox("The following data has been added to 'tblSections':" &
" & _
strFOLDER & Chr(13) & Chr(13) & "ENTRYID: " & strENTRYID & Chr(13)
& Chr(13) & "STOREID: " & strSTOREID, MsgBoxStyle.OkOnly, " Add
Complete -")
Why doesn't it work? I get no errors but the backend table is not updated
for some reason.
Donald Fisher
2007-08-29 22:01:08 UTC
Permalink
There is a data source for the app
(Outlook_Task_Reporting_Tool_1_0_2003DataSet) with a table named
"tblSections" that I'm adding a record to using the code in lines 25 &
26 of the message below (starting with the first >). I can get the
record to update in the app but not the data source.
Post by Scott M.
There is absolutely no code below that has anything to do with Access.
Perhaps this is why your Acees table is not getting updated?
I have an Access database as a data source and would like to add a record
Dim ol002 As New Microsoft.Office.Interop.Outlook.Application
Dim olns002 As Microsoft.Office.Interop.Outlook.NameSpace
Dim strENTRYID, strSTOREID, strFOLDER, strSECTION
olns002 = ol002.GetNamespace("MAPI")
Dim fldFolder As Microsoft.Office.Interop.Outlook.MAPIFolder
fldFolder = ol002.GetNamespace("MAPI").PickFolder
strENTRYID = fldFolder.EntryID
strSTOREID = fldFolder.StoreID
strSECTION = InputBox("Enter the section name as you would like it
to be displayed in the schedule [ALL CAPS]." & Chr(13) & Chr(13) & _
"Ensure this is the same name for a section already loaded.",
" Enter Section -")
strFOLDER = InputBox("Enter the exact name of the folder on your
public share for this section [ALL CAPS].", " Enter Share Name -")
Me._Outlook_Task_Reporting_Tool_1_0_2003DataSet.tblSections.AddtblSectionsRow(strSECTION,
strFOLDER, strENTRYID, strSTOREID).AcceptChanges()
MsgBox("The following data has been added to 'tblSections':" &
" & _
strFOLDER & Chr(13) & Chr(13) & "ENTRYID: " & strENTRYID & Chr(13)
& Chr(13) & "STOREID: " & strSTOREID, MsgBoxStyle.OkOnly, " Add
Complete -")
Why doesn't it work? I get no errors but the backend table is not updated
for some reason.
Scott M.
2007-09-01 16:24:33 UTC
Permalink
The code you show below does nothing but communicate with Outlook via COM
InterOP.

You've shown no code that has anything to do with a data source. We need to
see that code, as that is the code that will affect your underlying data
table.
Post by Donald Fisher
There is a data source for the app
(Outlook_Task_Reporting_Tool_1_0_2003DataSet) with a table named
"tblSections" that I'm adding a record to using the code in lines 25 & 26
of the message below (starting with the first >). I can get the record to
update in the app but not the data source.
Post by Scott M.
There is absolutely no code below that has anything to do with Access.
Perhaps this is why your Acees table is not getting updated?
Post by Donald Fisher
I have an Access database as a data source and would like to add a
Dim ol002 As New Microsoft.Office.Interop.Outlook.Application
Dim olns002 As Microsoft.Office.Interop.Outlook.NameSpace
Dim strENTRYID, strSTOREID, strFOLDER, strSECTION
olns002 = ol002.GetNamespace("MAPI")
Dim fldFolder As Microsoft.Office.Interop.Outlook.MAPIFolder
fldFolder = ol002.GetNamespace("MAPI").PickFolder
strENTRYID = fldFolder.EntryID
strSTOREID = fldFolder.StoreID
strSECTION = InputBox("Enter the section name as you would like
it to be displayed in the schedule [ALL CAPS]." & Chr(13) & Chr(13) & _
"Ensure this is the same name for a section already
loaded.", " Enter Section -")
strFOLDER = InputBox("Enter the exact name of the folder on your
public share for this section [ALL CAPS].", " Enter Share Name -")
Me._Outlook_Task_Reporting_Tool_1_0_2003DataSet.tblSections.AddtblSectionsRow(strSECTION,
strFOLDER, strENTRYID, strSTOREID).AcceptChanges()
MsgBox("The following data has been added to 'tblSections':" &
Chr(13) & Chr(13) & "SECTION: " & strSECTION & Chr(13) & Chr(13) &
"SHARE: " & _
strFOLDER & Chr(13) & Chr(13) & "ENTRYID: " & strENTRYID &
Chr(13) & Chr(13) & "STOREID: " & strSTOREID, MsgBoxStyle.OkOnly, " Add
Complete -")
Why doesn't it work? I get no errors but the backend table is not
updated for some reason.
Scott M.
2007-09-01 16:44:45 UTC
Permalink
To follow up on this, a DataSet is not a data source. It is an in-memory
representation of *some* data from *somewhere*. Updating a DataSet (as you
have seen) is not directly related to updated the data that populated your
DataSet.

Where is the code that shows your connection to Access?
Where is the code (I suspect you don't have any) that shows how you are
getting the updated DataSet data back into Access?

-Scott
Post by Scott M.
The code you show below does nothing but communicate with Outlook via COM
InterOP.
You've shown no code that has anything to do with a data source. We need
to see that code, as that is the code that will affect your underlying
data table.
Post by Donald Fisher
There is a data source for the app
(Outlook_Task_Reporting_Tool_1_0_2003DataSet) with a table named
"tblSections" that I'm adding a record to using the code in lines 25 & 26
of the message below (starting with the first >). I can get the record
to update in the app but not the data source.
Post by Scott M.
There is absolutely no code below that has anything to do with Access.
Perhaps this is why your Acees table is not getting updated?
Post by Donald Fisher
I have an Access database as a data source and would like to add a
Dim ol002 As New Microsoft.Office.Interop.Outlook.Application
Dim olns002 As Microsoft.Office.Interop.Outlook.NameSpace
Dim strENTRYID, strSTOREID, strFOLDER, strSECTION
olns002 = ol002.GetNamespace("MAPI")
Dim fldFolder As Microsoft.Office.Interop.Outlook.MAPIFolder
fldFolder = ol002.GetNamespace("MAPI").PickFolder
strENTRYID = fldFolder.EntryID
strSTOREID = fldFolder.StoreID
strSECTION = InputBox("Enter the section name as you would like
it to be displayed in the schedule [ALL CAPS]." & Chr(13) & Chr(13) & _
"Ensure this is the same name for a section already
loaded.", " Enter Section -")
strFOLDER = InputBox("Enter the exact name of the folder on
your public share for this section [ALL CAPS].", " Enter Share Name -")
Me._Outlook_Task_Reporting_Tool_1_0_2003DataSet.tblSections.AddtblSectionsRow(strSECTION,
strFOLDER, strENTRYID, strSTOREID).AcceptChanges()
MsgBox("The following data has been added to 'tblSections':" &
Chr(13) & Chr(13) & "SECTION: " & strSECTION & Chr(13) & Chr(13) &
"SHARE: " & _
strFOLDER & Chr(13) & Chr(13) & "ENTRYID: " & strENTRYID &
Chr(13) & Chr(13) & "STOREID: " & strSTOREID, MsgBoxStyle.OkOnly, " Add
Complete -")
Why doesn't it work? I get no errors but the backend table is not
updated for some reason.
Loading...