Reference Dataset in Another Form

I have a dataset (we'll call it Dataset1) that gets created, populated, etc programmatically in one of my forms (we'll call it FormA). It is declared in the declarations at the top of FormA....

Dim Dataset1 As New DataSet

Everything is great on this form (thanks a lot to everyone in this forum). However, now I need to run some checks against the dataset from another form (we'll call this one FormB).

This may sound a little rookie-ish, but how do I get to the dataset from my code on FormB Do I need to declare something on FormB or something along those lines

Any help would be great!

Thanks.

-- Jim



Answer this question

Reference Dataset in Another Form

  • Matt Ray

    ReneeC,

    You were dead on as always!

    Just for my own learning, why not use Dim statements What is the difference between Public and Dim statements

    God I'm really showing how naive I can be with some of this stuff!!

    Thanks again!

    -- Jim


  • Brett Metcalfe

    Sounded good to me!

    I added a Module and moved my Dim statements for the dataset and tables over to it, but now I get the nice blue squiggly line under any form where Dataset1 is used. When I hover over it, it says:

    Name 'Dataset1' is not declared.

    Any thoughts

    Thanks.

    -- Jim


  • c_marius

    What I do is to create a PUBLIC module called Common and keep my PUBLIC table and PUBLIC dataset definitions there. Then everyone can reference them.

  • Aneesh Abraham

     

    I bet you didn't declare  imports. Here is where I do it:

    Imports System.Data

    Imports System.Data.OleDb

    Public Module Common

    'I/O Related

    Public adodb As New ADONET(GetConnectionString)

    Public iosub As New IOSUBS

    Public CategoriesTable As New DataTable

    Public CurrentTable As New DataTable

    Public Adapter As OleDb.OleDbDataAdapter

    Public Dataset As New DataSet

    Public con As OleDb.OleDbConnection = New OleDb.OleDbConnection(GetConnectionString)

     

    And don't use dim statements. That's why I capitalized PUBLIC twice in my original response.



  • Reference Dataset in Another Form