How do you use one dataset in multiple forms?

  • Thread starter Thread starter John Holmes
  • Start date Start date
J

John Holmes

I have an application with a form that has bound controls to dataset.tables.
I have an Add button that brings up a modal form and I'd like to work with
the same instance of the dataset to insert new records and use combo boxes
that are populated from that dataset. The dataset gets filled when the
parent form loads. When I load the modal form I've tried accessing the
dataset in the parent form but I'm not having any luck.

Any help appreciated.

Thanks,

John
 
In your modal form ...

Private _parentDS as DataSet

Public Property ParentDS() as DataSet
Set
_parentDS = value
End Set
Get
Return _parentDS
End Get

In your parent form

Dim mdlDialog as new ModalForm
mdlDialog.ParentDS = myDS
mdlDialog.ShowDialog()


Instead of adding a reference to the dataset you could add a reference to
the parent form and access the data set that way.

Private _parentForm as Form

Public Property ParentForm() as Form
Set
_parentForm = value
End Set
Get
Return _parentForm
End Get

In parent ...
Dim mdlDialog as new ModalForm
mdlDialog.ParentForm = Me
mdlDialog.ShowDialog()

In modal again ...

Me.ParentForm.DS ....

-Joel
 
Back
Top