Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm looking for a way to get the scores of the students which are in the scores column in a data grid view which is bound with access and is in my view all data form to go to a timer which is in another form that will use that data to graph the scores on a chart.

I have googled pretty much everything that would come to mind but nothing either related to my problem or worked.

So if somebody can help me out, that would be awesome because I literally have no idea what to do!!

What I have tried:

I tried this from something I found on google:

I created a shared class...

Public Class dgvUserData
Public Shared Dt As New DataTable
Public Shared Bs As New BindingSource

End Class


On the view all data form I coded:

Public Class frmViewAllData
    Sub LoadData()
    SharedClass.Dt.Clear()
    SharedClass.Dt =
    SharedClass.Bs.DataSource = SharedClass.Dt
    dgvUserData.Datasource = SharedClass.Bs
    End Sub
    End Class


On the form that had the timer and chart I coded:

Public Class frmMonitorHeartRate
    Sub LoadData()
    dgvUserData.DataSource = SharedClass.Bs
    End Sub
    End Class
Posted
Updated 4-Aug-20 22:39pm
v2

For starters, you shouldn't be using Shared for this - it's a bad idea.

Instead, you should create a property in your frmMonitorHeartRate which your frmViewAllData uses to pass the source DataTable to it (assuming that the frmMonitorHeartRate instance is created by frmViewAllData, which you don't show).

Then in the frmViewAllData timer, you can peruse the DataTable (by using a For Each on the Rows property, and accessing each rows Cell(indexOfDataColumnYouAreIntestedIn) to get the two data items you need for your chart - the X and Y values - and display them in your chosen Chart.

Sounds complicated? It isn't, not really. It's just a case of getting your head around how things work!
Have a look at these.

The form that creates an instance of another:
C#
MyForm mf = new MyForm();
mf.Show();
Is the "parent", the other form is the "child".
(This doesn't imply any formal MDI relationship)

Transferring information between two forms, Part 1: Parent to Child[^]
Transferring information between two forms, Part 2: Child to Parent[^]
Transferring information between two forms, Part 3: Child to Child[^]

The code is in C#, but it's pretty obvious, and Code Converter C# to VB and VB to C# – Telerik[^] will convert anything you can't cope with.
You should only need the first one, but since I have no idea how your app works, it's possible the other two will help as well.
 
Share this answer
 
Comments
Merscy 10-Aug-20 20:55pm    
Hi there,
I tried those but they didn't work
OriginalGriff 11-Aug-20 1:37am    
They clearly do work, the demo code runs fine.
So the problem is clearly with how you implemented them ... and we have no idea what you did!
Merscy 11-Aug-20 4:28am    
Hi there,
sorry I wasn't trying to be rude or anything. Yes, you're right, the problem is with me as I think I could not tell which one related to mine and how I should implement them. I'm sorry this is probably frustrating, but if it's possible could you please tell me which one is which?

So pretty much, the frmMonitorHeartRate is the form that receives all the user input and the frmViewAllData is the form that has a dgvUserData which is a data table that shows all of the data that the user has entered. However, going back to frmMonitorHeartRate, there is a timer and a graph in there and I would like all the scores from the data table (dgvUserData) in the other form to be transferred to the timer in frmMonitorHeartRate. Once I manage to do that I've pretty much done the coding part for the timer to transfer the data to the chart, however, I'm not sure within the timer if I should mention dgvUserData (the name of the data table from the other form) or not. So with what I tried it kept on giving errors with when I mentioned the object like the timer or the dgvUserData or the parts where you give the codes about the form.

If you could help me out with figuring those out that would be great!!

I'm sorry for being a pain and thank you very much for your time already though. I wish I knew if there was actually a way to actually show you what's my problem at the start.
OriginalGriff 11-Aug-20 5:05am    
So which form creates and displays the other?
Merscy 11-Aug-20 6:06am    
umm, I'm not really sure what you mean, but the data table (dgvUserData) from the frmViewAllData form receives the user input from the frmMonitorHeartRate form...
Ok, it looks like you now need to load this
Dt As New DataTable
data-table from the access database - there's a clue or so here sql - vb.net Loading Images from Access Database to DataTable? - Stack Overflow[^]
 
Share this answer
 
Comments
Merscy 10-Aug-20 20:54pm    
Hi there,

I tried it but it didn't work
Garth J Lancaster 10-Aug-20 23:31pm    
That sort of response, to myself and OG (the other solution), is about as useful as tits on a boar - OG's solution in particular does work depending on the relationship between the forms - parent-child etc .. maybe you should update your question with your coding as per OG's notes - use Improve question
Merscy 11-Aug-20 4:41am    
Hi there,

Yes, I understand and sorry about that. You are right and I wasn't trying to be rude or anything and I know it may be frustrating but I've tried explaining why they didn't work for me in OG's reply and if you could please help me out with that, that would be great. I'm pretty sure I tried every one of those but it kept on giving errors with the recognising part I think... Also thanks for your time already as well...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900