Question Functions work only if form is run directly (non-MDI)

Super_Grover

Active member
Joined
Apr 7, 2010
Messages
32
Programming Experience
Beginner
Hi all,

I have this weird issue:
I developed an application with a sequence like this:
login form -> mainform (=mdi parent) --> some functionform (mdi-child)--> report form

The reportform contains a reportviewer and will display different dataset queries depending on the state of some radio buttons which are located on the previous form ('some function form').

When I run the project directly from the 'some function form' (set startup form for project) things work great. The report shows the correct data depending on choices made on the previous form.
But....when I run the project all the way from login and mainform it doesn't work. Seems like the choices made on the "some function form' are not coming through to the report form.

Any ideas what could be my prob?
Thanks in advance!
 
it doesn't work

Try and understand the difference between the following statements from our point of view :-

My car wont start. What could be wrong?

My car wont start. There is petrol in the tank, and the gauge is showing half full. The keys are in the ignition, the engine turns over but wont fire. What could be wrong?

You're asking us to try and comment on your project, without seeing ANY of your code. For example :-

choices made on the "some function form' are not coming through

How are you transferring the information? Global variables, form-based variables, classes, lists, etc etc. As I have said many times before, we arent mind readers :)

Having said all that, my guess would be that you are sending your choices to the wrong copy of your MDI child "some function form".
 
Yes, sorry for not including any code. I fully understand the 'my car won't start'-example and I know you're not mind readers. But I thought it had somerhing to do with MDI parent/child that I was not aware of. Something very general. So that's why I kept it very general. Sorry!

I'm not passing variables to the report form. All I do on the report form is checking the state of some radio buttons on the previous form:

VB.NET:
Private Sub Frm_rpt_epays_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        
        If Frm_some_functionSQL.rad_allCZ.Checked = True Then
            If Frm_some_functionSQL.rad_all.Checked = True Then
                Me.EPaysTableAdapter.Fill(Me.someSQLDataSet.EPays)
                ReportViewer1.Refresh()
                Me.Refresh()
            ElseIf Frm_some_functionSQL.rad_bet.Checked = True Then
                Me.EPaysTableAdapter.FillAllBet(Me.someSQLDataSet.EPays)
                ReportViewer1.Refresh()
                Me.Refresh()
            ElseIf Frm_some_functionSQL.rad_onbet.Checked = True Then
                Me.EPaysTableAdapter.FillAllOnbet(Me.someSQLDataSet.EPays)
                ReportViewer1.Refresh()
                Me.Refresh()
            End If
        ElseIf Frm_some_functionSQL.rad_verz.Checked = True Then
            If Frm_EPbetalingenSQL.rad_all.Checked = True Then
                Me.EPaysTableAdapter.FillAllVerz(Me.someSQLDataSet.EPays, gs_verz)
                ReportViewer1.Refresh()
                Me.Refresh()
            ElseIf Frm_some_functionSQL.rad_bet.Checked = True Then
                Me.EPaysTableAdapter.FillBetVerz(Me.someSQLDataSet.EPays, gs_verz)
                ReportViewer1.Refresh()
                Me.Refresh()
            ElseIf Frm_some_functionSQL.rad_onbet.Checked = True Then
                Me.EPaysTableAdapter.FillOnbetVerz(Me.someSQLDataSet.EPays, gs_verz)
                ReportViewer1.Refresh()
                Me.Refresh()
            End If
        End If

        Me.ReportViewer1.RefreshReport()
    End Sub


I double checked if I'm referring to the right copy of the form. It's the right one.

So again: if I run the 'some_function' form standalone and open the report form it shows the right query output depending on de the radio buttons on 'some_function'.
If I start the project from the start (login --> mainform --> some_function --> Frm_rpt_epays) it doesn't work.

Does this make it any clearer?
Thanks!
 
It sounds to me you are creating one or more instances of functionform from the mdi parent, but in report form you are referring to the default instance of functionform. If this is the case you can pass the correct functionform reference to reportform, or pass the values reportform needs.
 
Back
Top