By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,953 Members | 1,505 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,953 IT Pros & Developers. It's quick & easy.

Think is should be simple but carn`t find info:(

P: n/a
Hey Group,

Im Sure this is simple but I carn`t seem to find any info anywhere:(

I have 2 x Forms: Form 1 has a DataConnecter and several DataAdapters on it,
all bound together in my DataSet.

On My Table(Faxs) I have a relationship to another Table(MeterReadings), on
my Form I have a button called "Meter Reading".

How do I get it so that when I select a row from my Database in my datagrid
on my Form1, and click Meter Reading, it loads up Form2 with a Datagrid that
only shows me the meter Readings for the Fax Row I selected on Form 1? If
you get what I mean

Any Links Are help would be greatly appriciated.

Many Thanks
MCN

Nov 20 '05 #1
Share this Question
Share on Google+
25 Replies


P: n/a
Please use both groups (or all groups in the header so you don't mulitpost)
I answered this over in ADO.NET and I believe I had a more complete answer
to the same problem previously but i don't seem to see it right now.

DataRow dro = DataTable.Rows[dataGrid.SelectedRowIndex];

then pass dro to your new form. You can either create a property in the new
form, or create an overloaded constructor or function that takes a datarow
as a param and then bind to it.

HTH,

Bill

www.devbuzz.com
www.knowdotnet.com

"MadCrazyNewbie" <te**@nospam.com> wrote in message
news:0f********************@karoo.co.uk...
Hey Group,

Im Sure this is simple but I carn`t seem to find any info anywhere:(

I have 2 x Forms: Form 1 has a DataConnecter and several DataAdapters on it, all bound together in my DataSet.

On My Table(Faxs) I have a relationship to another Table(MeterReadings), on my Form I have a button called "Meter Reading".

How do I get it so that when I select a row from my Database in my datagrid on my Form1, and click Meter Reading, it loads up Form2 with a Datagrid that only shows me the meter Readings for the Fax Row I selected on Form 1? If
you get what I mean

Any Links Are help would be greatly appriciated.

Many Thanks
MCN

Nov 20 '05 #2

P: n/a
Hi Mad,

I was busy telling you the same as William did about the multipost, there is
no problem when you crosspost (send one message to more newsgroups) than
others can see if the answer you did get in the adonet group was right for
you.

Because I was busy and with another approach than William I send this also.

You said you had a made a datarelation and I hope binded the maintable using
setdatabinding to the dataset. Than you can do in my opinion something as:

\\\
Dim frm As New Form2
frm.DataGrid1.SetDataBinding(ds, _
"Maintable.DatarelationName")
frm.ShowDialog()
///

I hope this helps?
Cor

Nov 20 '05 #3

P: n/a
Cor,

Sorry I don`t understand what you mean bind the main table using
setdatabings?

Here is my code:

Private Sub frmMainMenuPasswords_Load(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MyBase.Load
cmDsFax = BindingContext(dsFax, "Faxs")
cmDsPhotoCopiers = BindingContext(dsPhotocopiers, "PhotoCopiers")
mlLoading = True
'Start of Fill Datasets
Try
dsFax.EnforceConstraints = False
dsPhotocopiers.EnforceConstraints = True
Try
Me.odcFaxCopiers.Open()
'Fill Fax Copier Datasets
Me.odaDepartments.Fill(dsFax)
Me.odaSites.Fill(dsFax)
Me.odaFaxs.Fill(dsFax)
'Fill PhotoCopier Datasets
Me.odaDepartments.Fill(dsPhotocopiers)
Me.odaSites.Fill(dsPhotocopiers)
Me.odaPhotoCopiers.Fill(dsPhotocopiers)
Catch fillException As System.Exception
Throw fillException
Finally
Me.odcFaxCopiers.Close()
End Try
Catch eLoad As System.Exception
System.Windows.Forms.MessageBox.Show(eLoad.Message )
Finally
mlLoading = False
End Try
'End of Fill Datasets
End Sub

'Start of Position Changed Code - Faxs
Private Sub cmdsFax_PositionChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmDsFax.PositionChanged
dsFax_PositionChanged()
End Sub
Private Sub cboFaxsDepartment_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
cboFaxsDepartment.SelectedIndexChanged
Me.BindingContext(dsFax, "Faxs").EndCurrentEdit()
If Me.BindingContext(dsFax, "Faxs").Position <> -1 And Not mlLoading
Then
dsFax.Faxs.Rows(Me.BindingContext(dsFax,
"Faxs").Position).Item("DepartmentID") = Me.cboFaxsDepartment.SelectedValue
End If
End Sub
Private Sub cbofaxsSite_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles cboFaxsSite.SelectedIndexChanged
Me.BindingContext(dsFax, "Faxs").EndCurrentEdit()
If Me.BindingContext(dsFax, "Faxs").Position <> -1 And Not mlLoading
Then
dsFax.Faxs.Rows(Me.BindingContext(dsFax,
"Faxs").Position).Item("SitesID") = Me.cboFaxsDepartment.SelectedValue
End If
End Sub
Private Sub dsFax_PositionChanged()
Me.BindingContext(dsFax, "Faxs").EndCurrentEdit()
If Me.BindingContext(dsFax, "Faxs").Position <> -1 And Not mlLoading
Then
Me.cboFaxsDepartment.SelectedValue =
dsFax.Faxs.Rows(Me.BindingContext(dsFax,
"Faxs").Position).Item("DepartmentID")
Me.cboFaxsSite.SelectedValue = dsFax.Faxs.Rows(Me.BindingContext(dsFax,
"Faxs").Position).Item("SitesID")
End If
End Sub

Many Again Thanks
MCN

'End of Position Changed Code - Faxs
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:OU**************@TK2MSFTNGP09.phx.gbl...
Hi Mad,

I was busy telling you the same as William did about the multipost, there is no problem when you crosspost (send one message to more newsgroups) than
others can see if the answer you did get in the adonet group was right for
you.

Because I was busy and with another approach than William I send this also.
You said you had a made a datarelation and I hope binded the maintable using setdatabinding to the dataset. Than you can do in my opinion something as:

\\\
Dim frm As New Form2
frm.DataGrid1.SetDataBinding(ds, _
"Maintable.DatarelationName")
frm.ShowDialog()
///

I hope this helps?
Cor

Nov 20 '05 #4

P: n/a
Hi Mad,

I do not see how the code has to do with the question.

I see nothing about a datagrid on form1 eiter on form1 or a relation to the
table "meterreading"

This is your text
---------------------------
On My Table(Faxs) I have a relationship to another Table(MeterReadings), on
my Form I have a button called "Meter Reading".

How do I get it so that when I select a row from my Database in my datagrid
on my Form1, and click Meter Reading, it loads up Form2 with a Datagrid that
only shows me the meter Readings for the Fax Row I selected on Form 1? If
you get what I mean
--------------------
What is the reason of my confusion?

Cor
Nov 20 '05 #5

P: n/a
He's got a valid point Si.

Follow Williams advice, its correct.

But to add...

Set a property on Form 2 for your key/index whatever you want to have the
forms data "based" off of..

so.. if the key in Faxes was idFax set a property in form 2 called idFax or
whatever you want..

Then...

.... williams stuff here.

.... find the row

dim myForm as Form2

myForm2.idFax = [therow id you found or whatever you want to set]

myform2.show()

in the property, do whatever you need to do to populate the grid

hope it helps,
cj

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:u8**************@tk2msftngp13.phx.gbl...
Hi Mad,

I do not see how the code has to do with the question.

I see nothing about a datagrid on form1 eiter on form1 or a relation to the table "meterreading"

This is your text
---------------------------
On My Table(Faxs) I have a relationship to another Table(MeterReadings), on my Form I have a button called "Meter Reading".

How do I get it so that when I select a row from my Database in my datagrid on my Form1, and click Meter Reading, it loads up Form2 with a Datagrid that only shows me the meter Readings for the Fax Row I selected on Form 1? If
you get what I mean
--------------------
What is the reason of my confusion?

Cor

Nov 20 '05 #6

P: n/a
Hi CJ,

When there is a relation created, than that code that I did provide works as
a charm with a datagrid and a dataset.

However with those comboboxes I go for a solution just providing the
selectedindex to the form and the dataset in a sub (that are only
references). Has the same simplisity.

Cor
Nov 20 '05 #7

P: n/a
Cor,

Not arguing your method. Just going off experience of working with Simon
and actually seeing a vast majority of the program (if not all of it) within
the past week.

Given his level of VB.NET, current undersatnding of different objects etc..
this just seemed to be the best approach for him.

No offense meant to either of you.

-CJ
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:OB**************@tk2msftngp13.phx.gbl...
Hi CJ,

When there is a relation created, than that code that I did provide works as a charm with a datagrid and a dataset.

However with those comboboxes I go for a solution just providing the
selectedindex to the form and the dataset in a sub (that are only
references). Has the same simplisity.

Cor

Nov 20 '05 #8

P: n/a
Hi CJ,

As forever I did understand what you wrote in your earlier message of
course, however this was what Bill wrote and and I am afraid that Simon and
I are on the same level, because I do not understand this. (I did not want
to write this but for the sake of Simon you forced me to that).

In this thread
--------------------
DataRow dro = DataTable.Rows[dataGrid.SelectedRowIndex];

then pass dro to your new form. You can either create a property in the new
form, or create an overloaded constructor or function that takes a datarow
as a param and then bind to it.
---------------------
And this in the ADONET group which I do not understand either
---------------------
Private _RowHolder As DataRow
Public Property RowHolder() As DataRow
Get
Return _RowHolder
End Get
Set(ByVal Value As DataRow)
_RowHolder = Value
End Set
End Property
Public Sub New(ByVal _Holder As DataRow)
Me.RowHolder = _Holder
End Sub

Then, no form1 use Dim frm as New
SecondGridForm(DataTableName.Rows[DataGrid.CurrentRowIndex])
frm.ShowDialog ' or .Show() depending on your needs
Then, once it's set you can do whatever you want on frm. Howver, if you
need the value you'll have it via frm.RowHolder as long as you remember to
reference on the second form with me.RowHolder
---------------------

Maybe you can explain this to us something deeper in the context of the
question from Simon?

(To make it something clearer, I can bind a table (or mostly an Ilist) as a
dataasource to any control however how to bind a datarow to a complex
control that do I not know).

Cor
Nov 20 '05 #9

P: n/a
Hey CJ/Cor/William,

Hope you could advise me a little again?

Now i`ve got in my Button Click Event on my first form(frmFaxs):

Dim LoadFaxMeterReadings As frmFaxMeterReadings()
LoadFaxMeterReadings.FaxID(BindingContext(dsFax, "Faxs").Position)
LoadFaxMeterReadings.Show()

(The Above tells me FAXID & Show are not members of System.Array)

On My Second form I have:

Public Property RowHolder() As DataRow
Get
Return RowHolder
End Get
Set(ByVal Value As DataRow)
RowHolder = Value
End Set
End Property

Public Sub New(ByVal Holder As DataRow)
Me.RowHolder = Holder
End Sub

Private Sub frmFaxMeterReadings_Load(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MyBase.Load
mlLoading = True
'Start of Fill Datasets
Try
dsFaxMeterReadings.EnforceConstraints = False
Try
Me.odcFaxMeterReadings.Open()
'Fill Arciris Roles Datasets
Me.odaFaxMeterReadings.Fill(dsFaxMeterReadings)
Catch fillException As System.Exception
Throw fillException
Finally
Me.odcFaxMeterReadings.Close()
End Try
Catch eLoad As System.Exception
System.Windows.Forms.MessageBox.Show(eLoad.Message )
Finally
mlLoading = False
End Try
'End of Fill Datasets
End Sub

Im I understanding this or am I going about this totally wrongs?

Many Thanks
MCN

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi CJ,

As forever I did understand what you wrote in your earlier message of
course, however this was what Bill wrote and and I am afraid that Simon and I are on the same level, because I do not understand this. (I did not want
to write this but for the sake of Simon you forced me to that).

In this thread
--------------------
DataRow dro = DataTable.Rows[dataGrid.SelectedRowIndex];

then pass dro to your new form. You can either create a property in the new form, or create an overloaded constructor or function that takes a datarow
as a param and then bind to it.
---------------------
And this in the ADONET group which I do not understand either
---------------------
Private _RowHolder As DataRow
Public Property RowHolder() As DataRow
Get
Return _RowHolder
End Get
Set(ByVal Value As DataRow)
_RowHolder = Value
End Set
End Property
Public Sub New(ByVal _Holder As DataRow)
Me.RowHolder = _Holder
End Sub

Then, no form1 use Dim frm as New
SecondGridForm(DataTableName.Rows[DataGrid.CurrentRowIndex])
frm.ShowDialog ' or .Show() depending on your needs
Then, once it's set you can do whatever you want on frm. Howver, if you
need the value you'll have it via frm.RowHolder as long as you remember to
reference on the second form with me.RowHolder
---------------------

Maybe you can explain this to us something deeper in the context of the
question from Simon?

(To make it something clearer, I can bind a table (or mostly an Ilist) as a dataasource to any control however how to bind a datarow to a complex
control that do I not know).

Cor

Nov 20 '05 #10

P: n/a
Hi Mad,

With the change to get angry messages from CJ and Bill, I give you my third
way to go, now I see how far you are. All is done in line and are the rows
without the >, deleted rows you have to check yourself. All typed in here by
hand and not in the designer so there can be typos. However in my opinion
this should go.

Dim LoadFaxMeterReadings As New frmFaxMeterReadings()
LoadFaxMeterReadings.FaxId= *The value from the combobox or the datagrid, I
do not know what it is now.* so if this stays a problem message that.
LoadFaxMeterReadings.Showdialog

In frmFaxMeterReading you add after the desinger created code

Public FaxId as string

You have probably to change your selection string, and I when you are using
SQL server
Then selection string has to be something like this
"SELECT * FROM Mytable WHERE Faxs = @Faxs"
Public Sub New(ByVal Holder As DataRow)
Me.RowHolder = Holder
End Sub

Private Sub frmFaxMeterReadings_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
mlLoading = True
odaFaxMeterReadings.SelectCommand.Parameters.Add(N ew SqlParameter("@Fax",
SqlDbType.Char, 30)).Value = FaxId
*** you have to set the right type and the lenght in this***********
'Start of Fill Datasets
Try
dsFaxMeterReadings.EnforceConstraints = False
Try
Me.odcFaxMeterReadings.Open()
'Fill Arciris Roles Datasets
Me.odaFaxMeterReadings.Fill(dsFaxMeterReadings)
Catch fillException As System.Exception
Throw fillException
Finally
Me.odcFaxMeterReadings.Close()
End Try
Catch eLoad As System.Exception
System.Windows.Forms.MessageBox.Show(eLoad.Message )
Finally
mlLoading = False
End Try
'End of Fill Datasets
dim dv as new dataview(dsFaxMeterReadings)
datagrid1.datasource = dv
End Sub


I hope this helps and hope as well on not to hard messages from CJ and Bill.

Cor
Nov 20 '05 #11

P: n/a
Cor,

Sorry but i don`t understand what goes here:
LoadFaxMeterReadings.FaxId= *The value from the combobox or the datagrid, I do not know what it is now*

also would I still use:
odaFaxMeterReadings.SelectCommand.Parameters.Add(N ew SqlParameter("@Fax",
SqlDbType.Char, 30)).Value = FaxId
Even though im using Access?

Many Thanks
MCN

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... Hi Mad,

With the change to get angry messages from CJ and Bill, I give you my third way to go, now I see how far you are. All is done in line and are the rows
without the >, deleted rows you have to check yourself. All typed in here by hand and not in the designer so there can be typos. However in my opinion
this should go.

Dim LoadFaxMeterReadings As New frmFaxMeterReadings()
LoadFaxMeterReadings.FaxId= *The value from the combobox or the datagrid, I do not know what it is now.* so if this stays a problem message that.
LoadFaxMeterReadings.Showdialog

In frmFaxMeterReading you add after the desinger created code

Public FaxId as string

You have probably to change your selection string, and I when you are

using SQL server
Then selection string has to be something like this
"SELECT * FROM Mytable WHERE Faxs = @Faxs"
Public Sub New(ByVal Holder As DataRow)
Me.RowHolder = Holder
End Sub

Private Sub frmFaxMeterReadings_Load(ByVal sender As System.Object,
ByVal e
As System.EventArgs) Handles MyBase.Load
mlLoading = True
odaFaxMeterReadings.SelectCommand.Parameters.Add(N ew SqlParameter("@Fax",
SqlDbType.Char, 30)).Value = FaxId
*** you have to set the right type and the lenght in this***********
'Start of Fill Datasets
Try
dsFaxMeterReadings.EnforceConstraints = False
Try
Me.odcFaxMeterReadings.Open()
'Fill Arciris Roles Datasets
Me.odaFaxMeterReadings.Fill(dsFaxMeterReadings)
Catch fillException As System.Exception
Throw fillException
Finally
Me.odcFaxMeterReadings.Close()
End Try
Catch eLoad As System.Exception
System.Windows.Forms.MessageBox.Show(eLoad.Message )
Finally
mlLoading = False
End Try
'End of Fill Datasets


dim dv as new dataview(dsFaxMeterReadings)
datagrid1.datasource = dv
End Sub


I hope this helps and hope as well on not to hard messages from CJ and

Bill.
Cor

Nov 20 '05 #12

P: n/a
Hi Mad,

I try to explain it in words.

What we are doing now is create an public variable in your second form.
That has to be the Id of the fax as it is selected in: And here I am not
sure if that is a combobox on your form1 or a datagrid, when I know that I
can tell something more.

Than we open the form2 and give the FaxId to that.
In that form2 you are reading the Faxdataset I saw, however we limit it to
only the faxId you did want.

The OleDB needs some litle changes. the Select string becomes for OleDB
(access) something as.
"SELECT * FROM Mytable WHERE Fax = ?"

And the parameter becomes (if you have set an imports to system.IO.oledb)
odaFaxMeterReadings.SelectCommand.Parameters.Add(N ew OleDbParameter("Fax",
OleDbType.Char)).Value = FaxId

http://msdn.microsoft.com/library/de...sAddTopic2.asp

However tell me about where we get that FaxId?

Cor
Nov 20 '05 #13

P: n/a
Hi Cor, sorry again about my other post my post still hasn`t show up on
outlook:( anyways.

On my Faxs Form (Form1) i have a datagrid and serveral comboboxs, however I
want the user to selct the row via the datagird. once they have selected the
row they click on the FaxMeterReadings button to take them to
FaxMeterReadings (Form2)

Thanks Again
MCN

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi Mad,

I try to explain it in words.

What we are doing now is create an public variable in your second form.
That has to be the Id of the fax as it is selected in: And here I am not
sure if that is a combobox on your form1 or a datagrid, when I know that I
can tell something more.

Than we open the form2 and give the FaxId to that.
In that form2 you are reading the Faxdataset I saw, however we limit it to
only the faxId you did want.

The OleDB needs some litle changes. the Select string becomes for OleDB
(access) something as.
"SELECT * FROM Mytable WHERE Fax = ?"

And the parameter becomes (if you have set an imports to system.IO.oledb)
odaFaxMeterReadings.SelectCommand.Parameters.Add(N ew OleDbParameter("Fax",
OleDbType.Char)).Value = FaxId

http://msdn.microsoft.com/library/de...sAddTopic2.asp
However tell me about where we get that FaxId?

Cor

Nov 20 '05 #14

P: n/a
Ok

Then you need something as this in your button event on form1

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim frm2 As New Form2
frm2.faxId = Me.DataGrid1.Item(DataGrid1.CurrentRowIndex, 0).ToString
frm2.ShowDialog()
End Sub

The 0 you see is the columnindex from the datagrid where the faxId is
located.
So that is one of the things you have to change.

Now it should work.
And when not tell what happens.

Cor

On my Faxs Form (Form1) i have a datagrid and serveral comboboxs, however I want the user to selct the row via the datagird. once they have selected the row they click on the FaxMeterReadings button to take them to
FaxMeterReadings (Form2)

Nov 20 '05 #15

P: n/a
Cor,

It tells me that FaxID is not a Member of FaxMeterReadingsForm

What do I need to set as FaxID? CJ said to set a property on the Form for my
Key/Index? whats does this need to be?

Many Thanks Again
MCN

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Ok

Then you need something as this in your button event on form1

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim frm2 As New Form2
frm2.faxId = Me.DataGrid1.Item(DataGrid1.CurrentRowIndex, 0).ToString frm2.ShowDialog()
End Sub

The 0 you see is the columnindex from the datagrid where the faxId is
located.
So that is one of the things you have to change.

Now it should work.
And when not tell what happens.

Cor

On my Faxs Form (Form1) i have a datagrid and serveral comboboxs,
however I
want the user to selct the row via the datagird. once they have selected

the
row they click on the FaxMeterReadings button to take them to
FaxMeterReadings (Form2)


Nov 20 '05 #16

P: n/a
Cor,

Another Thing I have on my FaxMeterReadingTable:

MeterReadingID(PrimaryKey), FaxID(Lookup to FaxID(PrimaryKey of My Fax
Table), Date, & Reading.

I think i`ve built the table right as my Parent Table is Faxs and my Child
Table is FaxMeterReadings (Belive i`ve got it right in a One-Two-Many
Relationship)

Just thought id better check My Database Was right first

Thanks Again
MCN

"MadCrazyNewbie" <te**@nospam.com> wrote in message
news:E9********************@karoo.co.uk...
Cor,

It tells me that FaxID is not a Member of FaxMeterReadingsForm

What do I need to set as FaxID? CJ said to set a property on the Form for my Key/Index? whats does this need to be?

Many Thanks Again
MCN

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Ok

Then you need something as this in your button event on form1

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim frm2 As New Form2
frm2.faxId = Me.DataGrid1.Item(DataGrid1.CurrentRowIndex,

0).ToString
frm2.ShowDialog()
End Sub

The 0 you see is the columnindex from the datagrid where the faxId is
located.
So that is one of the things you have to change.

Now it should work.
And when not tell what happens.

Cor

On my Faxs Form (Form1) i have a datagrid and serveral comboboxs, however
I
want the user to selct the row via the datagird. once they have

selected the
row they click on the FaxMeterReadings button to take them to
FaxMeterReadings (Form2)



Nov 20 '05 #17

P: n/a
Did you do this as I wrote?

In FaxMeterReadingForm you add after the desinger created code

Public FaxId as string

Cor

It tells me that FaxID is not a Member of FaxMeterReadingsForm

Nov 20 '05 #18

P: n/a
Hi Simon,

I think that you can better first make this to an end and than look how to
optimize it.
You are almost there that there will be a table displayed.

Cor
Nov 20 '05 #19

P: n/a
Sorry Cor,

I misted that one:( Right cool seems to load up my form now:) only thing is
it dosn`t display the meter reading for just that fax I selected, instead is
fills my DataGrid with All Details from All Faxs:(

Any Ideas?

Many Thanks
MCN
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Did you do this as I wrote?

In FaxMeterReadingForm you add after the desinger created code

Public FaxId as string

Cor

It tells me that FaxID is not a Member of FaxMeterReadingsForm


Nov 20 '05 #20

P: n/a
Hi Mad,

That was this part
The OleDB needs some litle changes. the Select string becomes for OleDB
(access) something as.
"SELECT * FROM Mytable WHERE Fax = ?"

Should be your table of course and the right name for the faxId field in
your accessfile.

And than this right before the fill

Also with the right name (this is case sensetive) for the faxId.

odaFaxMeterReadings.SelectCommand.Parameters.Add(N ew OleDbParameter("Fax",
OleDbType.Char)).Value = FaxId
http://msdn.microsoft.com/library/de...sAddTopic2.asp

Than it should give only the one fax you selected,

Cor


I misted that one:( Right cool seems to load up my form now:) only thing is it dosn`t display the meter reading for just that fax I selected, instead is fills my DataGrid with All Details from All Faxs:(

Any Ideas?

Many Thanks
MCN
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Did you do this as I wrote?

In FaxMeterReadingForm you add after the desinger created code

Public FaxId as string

Cor

It tells me that FaxID is not a Member of FaxMeterReadingsForm



Nov 20 '05 #21

P: n/a
Cor,

Do I need to put the "SELECT * FROM Faxs WHERE Fax = FaxID" in My
DataAdapter on Form 2?

On my Form 2 I`ve created 2 x Dataadapters odaFaxs, and odaFaxMeterReadings
and bound them in my DS.

Now on my form 2 x I have:

Me.odcFaxMeterReadings.Open()
odaFaxMeterReading.SelectCommand.Parameters.Add(Ne w
OleDb.OleDbParameter("Checked", OleDb.OleDbType.Char)).Value = FaxId
Me.odaFaxs.Fill(dsFaxMeterReadings)
Me.odaFaxMeterReading.Fill(dsFaxMeterReadings)
Catch fillException As System.Exception
Throw fillException
Finally
Me.odcFaxMeterReadings.Close()

Is this Correct? or im I understanding wrong?

When I click on my FaxMeterReading Button on Form one I get a error saying
"No Value Given for one or more Parameters"

MAny Thanks Again
MCN

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:Ox**************@TK2MSFTNGP09.phx.gbl...
Hi Mad,

That was this part
The OleDB needs some litle changes. the Select string becomes for OleDB
(access) something as.
"SELECT * FROM Mytable WHERE Fax = ?"

Should be your table of course and the right name for the faxId field in
your accessfile.

And than this right before the fill

Also with the right name (this is case sensetive) for the faxId.

odaFaxMeterReadings.SelectCommand.Parameters.Add(N ew OleDbParameter("Fax",
OleDbType.Char)).Value = FaxId
http://msdn.microsoft.com/library/de...sAddTopic2.asp
Than it should give only the one fax you selected,

Cor


I misted that one:( Right cool seems to load up my form now:) only thing is
it dosn`t display the meter reading for just that fax I selected,

instead is
fills my DataGrid with All Details from All Faxs:(

Any Ideas?

Many Thanks
MCN
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Did you do this as I wrote?

In FaxMeterReadingForm you add after the desinger created code

Public FaxId as string

Cor
>
> It tells me that FaxID is not a Member of FaxMeterReadingsForm
>



Nov 20 '05 #22

P: n/a
Hi Mad,

It is in this approach important that in Form2 only the selected fax is
readed.

So I am talking about the selectionstring from that, somewhere there has to
be a selectionstring in that form, because you fill it from that, ( I assume
you have no shared database class now).

And that is than the one for which for the faxes this WHERE part in my
opinion should be added.

Cor

Do I need to put the "SELECT * FROM Faxs WHERE Fax = FaxID" in My
DataAdapter on Form 2?

On my Form 2 I`ve created 2 x Dataadapters odaFaxs, and odaFaxMeterReadings and bound them in my DS.

Now on my form 2 x I have:

Me.odcFaxMeterReadings.Open()
odaFaxMeterReading.SelectCommand.Parameters.Add(Ne w
OleDb.OleDbParameter("Checked", OleDb.OleDbType.Char)).Value = FaxId
Me.odaFaxs.Fill(dsFaxMeterReadings)
Me.odaFaxMeterReading.Fill(dsFaxMeterReadings)
Catch fillException As System.Exception
Throw fillException
Finally
Me.odcFaxMeterReadings.Close()

Is this Correct? or im I understanding wrong?

When I click on my FaxMeterReading Button on Form one I get a error saying
"No Value Given for one or more Parameters"

Nov 20 '05 #23

P: n/a
Sorry Cor,

I think im lost again:( Do you mean:

On Both My DataAdapeters use the following "SELECT * From <TABLENAME>

Then in my code:

Dim sqlFaxMeterReadings As sqlString
sqlFaxMeterReadings = "SELECT * FROM Faxs WHERE Fax = FaxID"

If the above is correct and im not getting confused, how do I tell it to use
that on my .Fill or .Open commands?

Many Thanks
MCN

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:uz**************@TK2MSFTNGP12.phx.gbl...
Hi Mad,

It is in this approach important that in Form2 only the selected fax is
readed.

So I am talking about the selectionstring from that, somewhere there has to be a selectionstring in that form, because you fill it from that, ( I assume you have no shared database class now).

And that is than the one for which for the faxes this WHERE part in my
opinion should be added.

Cor

Do I need to put the "SELECT * FROM Faxs WHERE Fax = FaxID" in My
DataAdapter on Form 2?

On my Form 2 I`ve created 2 x Dataadapters odaFaxs, and

odaFaxMeterReadings
and bound them in my DS.

Now on my form 2 x I have:

Me.odcFaxMeterReadings.Open()
odaFaxMeterReading.SelectCommand.Parameters.Add(Ne w
OleDb.OleDbParameter("Checked", OleDb.OleDbType.Char)).Value = FaxId
Me.odaFaxs.Fill(dsFaxMeterReadings)
Me.odaFaxMeterReading.Fill(dsFaxMeterReadings)
Catch fillException As System.Exception
Throw fillException
Finally
Me.odcFaxMeterReadings.Close()

Is this Correct? or im I understanding wrong?

When I click on my FaxMeterReading Button on Form one I get a error saying "No Value Given for one or more Parameters"


Nov 20 '05 #24

P: n/a
Hi Max,

show those selectstrings in your dataadapters as they are now (only form2),
than I think I get more information

Cor

Nov 20 '05 #25

P: n/a
Many Thanks to Cor, Who has helped me with the problem Offline (After about
30 e-mails)

Many Thanks Again - Cor

Thanks
MCN

"MadCrazyNewbie" <te**@nospam.com> wrote in message
news:dz********************@karoo.co.uk...
On its way.

Thanks
MCN

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:OU****************@TK2MSFTNGP11.phx.gbl...
Hi Mad,

My adres is in my mail it is original however notmyfirstname, only my
lastname.

Cor


Nov 20 '05 #26

This discussion thread is closed

Replies have been disabled for this discussion.