J
Jeff Brown
OK i have came to the conclusion that since this app will be run on multiple computers that loading a complete database and then updating on exit is a moot point. I have tried several ideas submitted, but i am unable to get one of them to work completely. Here is the code i had before i realized that when i filled the dataset in the form load procedure that it would "ruin, replace, mess up" the dataset named the same thing on the other form. Below is my Update, Add, Edit and Cancel code and an exerpt from the form load which like i say, worked fine before i realized i would have to change where i declared my datasets. Do i need to programmtically code my datasets in a module, (someone else mentioned that) and if so how? so that every time a childform is loaded or made active it has an updated set of data? and i do not have several datasets containing the same data? The way i was currently headed i would have had a trailers dataset containing all trailer info and a seperate dataset containing only trailer numbers for use in another form. I have been reading all day, and am still just about where i was earlier.
I tried this and got syntax errors.
childs form class
dim tform as mdiMainForm (whatever the type is)
tForm = me.mdiParent
me.dsWhatever.merge (tForm.dsName1)
"PLEASE NOTE: The parts that were commented out worked great until i realized they wouldn't work... uh.. well you know what i mean.
Form Load
Private Const cblnEditing As Boolean = True
Private Const cblnNotEditing As Boolean = False
' I used to fill them this way beacuse they were created on the child form, but that doesn't work since each child form has at least 2 of these
' So I asked and was given the right idea and think i have a pretty good understanding now, but i still do not know where or how to declare my 'datasets any differently so that each form can access them and be updated when the active child changes.
odbdaTrailers.fill(dsTrailers1)
odbdaTrucks.fill(dsTrucks1)
odbdaDrivers.fill(dsDrivers1)
.....ETC ETC ETC
End Form Load
Private Sub AddData()
' Set the menu items to indicate that a record is being edited.
Call EditState(cblnEditing)
' Add a new record.
'Worked the whole way but not since i need the portions of the same dataset across multiple forms
'Me.BindingContext(DsTrailers1, "equipTrailers").AddNew()
End Sub
Private Sub EditData()
Call EditState(cblnEditing)
End Sub
Private Sub CancelData()
' Update the menu items to not editing.
Call EditState(cblnNotEditing)
'Me.BindingContext(DsTrailers1, "EquipTrailers").CancelCurrentEdit()
End Sub
Private Sub UpdateData()
' Temporary DataSets to store the inserted or modified row.
Dim pdsInsertedRows, pdsModifiedRows As DataSet
' Set the menu items to editing.
Call EditState(cblnNotEditing)
' End editing on the current record.
' Me.BindingContext(DsTrailers1, "equiptrailers").EndCurrentEdit()
' Copy the DataSets by getting added/modified records from original DataSet.
'pdsInsertedRows = DsTrailers1.GetChanges(DataRowState.Added)
'pdsModifiedRows = DsTrailers1.GetChanges(DataRowState.Modified)
' Check to see if there is an inserted row. If there is update DataSet.
If Not pdsInsertedRows Is Nothing Then
' odbdaTrailers.Update(pdsInsertedRows)
End If
' Check to see if there is a modified row. If there is update dataset
If Not pdsModifiedRows Is Nothing Then
' odbdaTrailers.Update(pdsModifiedRows)
End If
' Synchronize the database to dataset
' DsTrailers1.AcceptChanges()
End Sub
I tried this and got syntax errors.
childs form class
dim tform as mdiMainForm (whatever the type is)
tForm = me.mdiParent
me.dsWhatever.merge (tForm.dsName1)
"PLEASE NOTE: The parts that were commented out worked great until i realized they wouldn't work... uh.. well you know what i mean.
Form Load
Private Const cblnEditing As Boolean = True
Private Const cblnNotEditing As Boolean = False
' I used to fill them this way beacuse they were created on the child form, but that doesn't work since each child form has at least 2 of these
' So I asked and was given the right idea and think i have a pretty good understanding now, but i still do not know where or how to declare my 'datasets any differently so that each form can access them and be updated when the active child changes.
odbdaTrailers.fill(dsTrailers1)
odbdaTrucks.fill(dsTrucks1)
odbdaDrivers.fill(dsDrivers1)
.....ETC ETC ETC
End Form Load
Private Sub AddData()
' Set the menu items to indicate that a record is being edited.
Call EditState(cblnEditing)
' Add a new record.
'Worked the whole way but not since i need the portions of the same dataset across multiple forms
'Me.BindingContext(DsTrailers1, "equipTrailers").AddNew()
End Sub
Private Sub EditData()
Call EditState(cblnEditing)
End Sub
Private Sub CancelData()
' Update the menu items to not editing.
Call EditState(cblnNotEditing)
'Me.BindingContext(DsTrailers1, "EquipTrailers").CancelCurrentEdit()
End Sub
Private Sub UpdateData()
' Temporary DataSets to store the inserted or modified row.
Dim pdsInsertedRows, pdsModifiedRows As DataSet
' Set the menu items to editing.
Call EditState(cblnNotEditing)
' End editing on the current record.
' Me.BindingContext(DsTrailers1, "equiptrailers").EndCurrentEdit()
' Copy the DataSets by getting added/modified records from original DataSet.
'pdsInsertedRows = DsTrailers1.GetChanges(DataRowState.Added)
'pdsModifiedRows = DsTrailers1.GetChanges(DataRowState.Modified)
' Check to see if there is an inserted row. If there is update DataSet.
If Not pdsInsertedRows Is Nothing Then
' odbdaTrailers.Update(pdsInsertedRows)
End If
' Check to see if there is a modified row. If there is update dataset
If Not pdsModifiedRows Is Nothing Then
' odbdaTrailers.Update(pdsModifiedRows)
End If
' Synchronize the database to dataset
' DsTrailers1.AcceptChanges()
End Sub