Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

Hi all

 

I have a dateset whose contents can be changed by the user. Usually the user would click the save button when they are finished making the changes. However, if they forget to click on the save button, I want to simply offer them the opportunity to do so when the FormClosing event is fired. Here is my code so far:

   Private Sub frmGeneralQueries_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
       Select Case mintReport
           Case frmMain.mcTotalByOrganisation
               If Not dsPRTRDisplay.Tables("TotalByOrganisation").GetChanges.Rows.Count = 0 Then
                   If MessageBox.Show("Your changes have not been saved.  Do you want to Save them?", "Save Changes", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.Yes Then
                       AllowSaveChanges()
                   End If
               End If
       End Select
   End Sub

 

The above code works in the event that there was a change that the user had not already save, however, I am getting problems if no changes exist. I know that I could use dataset.haschanges, however, there is no guarantee that the dataset in question would only have one table in it.

 

Error message is: NullReferenceException - Object Reference not set to an instance of an object.

 

Any suggestions?

 

Mike55.

Edited by mike55

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...