473,569 Members | 2,870 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

determine after using addnew

is there a way to know if the form is edited or not after calling
addnew? Me.BindingConte xt(DsStudentCou rse1, "Students").Add New()

because i got an error after closing the form. because in my form
closing event i have a code to call the EndCurrentEdit to determine if
the dataset has changes or not. here is my code in closing event

Private Sub Students_Closin g(ByVal sender As Object, ByVal e
As System.Componen tModel.CancelEv entArgs) Handles MyBase.Closing
Me.BindingConte xt(DsStudentCou rse1,
"Students").End CurrentEdit()
Try
If DsStudentCourse 1.HasChanges Then
If MessageBox.Show ("There are unsave changes in
the Form, Yes to Save, No to Discard and exit?", "Save changes",
MessageBoxButto ns.YesNo, MessageBoxIcon. Question) = DialogResult.Ye s
Then
Save_Record()
Else
Me.BindingConte xt(DsStudentCou rse1,
"Students").Can celCurrentEdit( )
End If
End If
Catch ex As Exception
MessageBox.Show (ex.Message)
End Try
End Sub

the problem is in the Me.BindingConte xt(DsStudentCou rse1,
"Students").End CurrentEdit() line of code after calling addnew and
then closing the form without editing the form.

the error generated is "Column 'IDNo' does not allow nulls." because
IDNo is a primary key.

thanks in advance for any help.
Nov 20 '05 #1
3 1837
I don't know of a way to determine its state, but why not call cancel
current edit. you can tell if the dataset has changes or not by using
DataSet.HasChan ges(); which returns a bool. If it doesn't go ahead and
cancel the current edit (depending on how you want the app to behave this
should do it for you).
"jaYPee" <hi******@yahoo .com> wrote in message
news:vm******** *************** *********@4ax.c om...
is there a way to know if the form is edited or not after calling
addnew? Me.BindingConte xt(DsStudentCou rse1, "Students").Add New()

because i got an error after closing the form. because in my form
closing event i have a code to call the EndCurrentEdit to determine if
the dataset has changes or not. here is my code in closing event

Private Sub Students_Closin g(ByVal sender As Object, ByVal e
As System.Componen tModel.CancelEv entArgs) Handles MyBase.Closing
Me.BindingConte xt(DsStudentCou rse1,
"Students").End CurrentEdit()
Try
If DsStudentCourse 1.HasChanges Then
If MessageBox.Show ("There are unsave changes in
the Form, Yes to Save, No to Discard and exit?", "Save changes",
MessageBoxButto ns.YesNo, MessageBoxIcon. Question) = DialogResult.Ye s
Then
Save_Record()
Else
Me.BindingConte xt(DsStudentCou rse1,
"Students").Can celCurrentEdit( )
End If
End If
Catch ex As Exception
MessageBox.Show (ex.Message)
End Try
End Sub

the problem is in the Me.BindingConte xt(DsStudentCou rse1,
"Students").End CurrentEdit() line of code after calling addnew and
then closing the form without editing the form.

the error generated is "Column 'IDNo' does not allow nulls." because
IDNo is a primary key.

thanks in advance for any help.

Nov 20 '05 #2
thanks for the reply. however DataSet.HasChan ges() is only applicable
when the control is datagrid. don't know if i'm wrong or not. but as i
have experience eventhough i edit the textbox in my form and close the
form and call DataSet.HasChan ges() is it returns false.
On Wed, 28 Apr 2004 00:28:47 -0400, "William Ryan eMVP"
<do********@com cast.nospam.net > wrote:
I don't know of a way to determine its state, but why not call cancel
current edit. you can tell if the dataset has changes or not by using
DataSet.HasCha nges(); which returns a bool. If it doesn't go ahead and
cancel the current edit (depending on how you want the app to behave this
should do it for you).
"jaYPee" <hi******@yahoo .com> wrote in message
news:vm******* *************** **********@4ax. com...
is there a way to know if the form is edited or not after calling
addnew? Me.BindingConte xt(DsStudentCou rse1, "Students").Add New()

because i got an error after closing the form. because in my form
closing event i have a code to call the EndCurrentEdit to determine if
the dataset has changes or not. here is my code in closing event

Private Sub Students_Closin g(ByVal sender As Object, ByVal e
As System.Componen tModel.CancelEv entArgs) Handles MyBase.Closing
Me.BindingConte xt(DsStudentCou rse1,
"Students").End CurrentEdit()
Try
If DsStudentCourse 1.HasChanges Then
If MessageBox.Show ("There are unsave changes in
the Form, Yes to Save, No to Discard and exit?", "Save changes",
MessageBoxButto ns.YesNo, MessageBoxIcon. Question) = DialogResult.Ye s
Then
Save_Record()
Else
Me.BindingConte xt(DsStudentCou rse1,
"Students").Can celCurrentEdit( )
End If
End If
Catch ex As Exception
MessageBox.Show (ex.Message)
End Try
End Sub

the problem is in the Me.BindingConte xt(DsStudentCou rse1,
"Students").End CurrentEdit() line of code after calling addnew and
then closing the form without editing the form.

the error generated is "Column 'IDNo' does not allow nulls." because
IDNo is a primary key.

thanks in advance for any help.


Nov 20 '05 #3
Actually, that's not true. HasChanges has nothign to do with a
Datagrid...the datagrid is only incidental in that it's one mechanism to
edit the data. If HasChanges is false, your update isn't going to do
anything. TO prove it, trap the StateChanged event of your connection. Put
a messagebox in it. Then, right after dataadapter.fil l the very next line
(test HasChanges, it will be false). Next, create a loop to 1000 or 10000
or whatever suits you. Then, in the loop call daadapter.Updat e. You'll
notice that your messagebox never shows. That's because the connection
(which is closed at this point) doesn't open any more (while in the loop
calling Update) which proves it's not sending anything to the db. Next
line, Change a value of the datatable. call dataAdapter.Upd ate again, your
messagebox will show this time. It will show twice on fill, once when it
opens, once when it closes.

hasChanges is a property of the dataset not the grid.
jaYPee" <hi******@yahoo .com> wrote in message
news:f1******** *************** *********@4ax.c om...
thanks for the reply. however DataSet.HasChan ges() is only applicable
when the control is datagrid. don't know if i'm wrong or not. but as i
have experience eventhough i edit the textbox in my form and close the
form and call DataSet.HasChan ges() is it returns false.
On Wed, 28 Apr 2004 00:28:47 -0400, "William Ryan eMVP"
<do********@com cast.nospam.net > wrote:
I don't know of a way to determine its state, but why not call cancel
current edit. you can tell if the dataset has changes or not by using
DataSet.HasCha nges(); which returns a bool. If it doesn't go ahead and
cancel the current edit (depending on how you want the app to behave this
should do it for you).
"jaYPee" <hi******@yahoo .com> wrote in message
news:vm******* *************** **********@4ax. com...
is there a way to know if the form is edited or not after calling
addnew? Me.BindingConte xt(DsStudentCou rse1, "Students").Add New()

because i got an error after closing the form. because in my form
closing event i have a code to call the EndCurrentEdit to determine if
the dataset has changes or not. here is my code in closing event

Private Sub Students_Closin g(ByVal sender As Object, ByVal e
As System.Componen tModel.CancelEv entArgs) Handles MyBase.Closing
Me.BindingConte xt(DsStudentCou rse1,
"Students").End CurrentEdit()
Try
If DsStudentCourse 1.HasChanges Then
If MessageBox.Show ("There are unsave changes in
the Form, Yes to Save, No to Discard and exit?", "Save changes",
MessageBoxButto ns.YesNo, MessageBoxIcon. Question) = DialogResult.Ye s
Then
Save_Record()
Else
Me.BindingConte xt(DsStudentCou rse1,
"Students").Can celCurrentEdit( )
End If
End If
Catch ex As Exception
MessageBox.Show (ex.Message)
End Try
End Sub

the problem is in the Me.BindingConte xt(DsStudentCou rse1,
"Students").End CurrentEdit() line of code after calling addnew and
then closing the form without editing the form.

the error generated is "Column 'IDNo' does not allow nulls." because
IDNo is a primary key.

thanks in advance for any help.

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
6446
by: Phillip J. Allen | last post by:
Hi all, I have a table with an “autonumber” primary key field that also acts as a foreign key in 2 other tables. I would like to programmatically add a new record to the first table and the other 2 child tables. The reason for doing this is to copy one complete record (parent and child table records) into a new record so the user can make...
40
2936
by: Jeff | last post by:
I have a system on a network and want to determine if anyone is currently connected to the back-end files. An interesting twist is that I have noticed that some users can be connected (have the front end open at the first form) and even though this links to the back-end files, there are no ldb files created. This is so I know when it is...
2
1357
by: guy | last post by:
if i use Generics.AddNew how do I pass an object to the items constructor? I have a set of class all inheriting from a base class, all requiring one parameter on their constructor - the data passed to it will be the same independent of the class type so how do i pass it to AddNew?
2
3830
by: pillmill | last post by:
I replaced AddNew statments with INSERT INTO, but am unable to write to the same tables. Foreign keys violations are the main errors. Why are these occuring ? Before: set rs3= db.OpenRecordset("tblMat", dbOpenDynaset) rs3.AddNew rs3!Mat = Rs!Mat rs3.Update
6
2199
by: Robin Lawrie | last post by:
Hi, Looking for some help here! I'm adding records to a SQL 2000 DB using the objRS.AddNew and objRS.Update methods. What I'd like to do is determine the new primary key value of the added record.
8
2339
by: MLH | last post by:
Here's a snippet from A97 HELP on AddNew... The record that was current before you used AddNew remains current. If you want to make the new record current, you can set the Bookmark property to the bookmark identified by the LastModified property setting. My own experience is indicating that the newly added record becomes current during...
10
12677
by: MLH | last post by:
Suppose, in a multi-user environment, you have append query SQL in a VBA procedure that looks like INSERT INTO MyTable... and the next line reads MyVar=DMax("","MyTable... You can never be certain that MyVar will be set to the key-field value that was created when the Append query ran. Now, there are other ways to do it - I know - that...
1
2454
by: teenagelcruise | last post by:
hi, i have a problem with my code which is i cannot update and addnew data into the database but i can delete the data.plz give me an idea.this is my code that i wrote. <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Order Record</title> <meta name="Microsoft Border" content="tlb, default">...
0
1071
by: durga2005 | last post by:
Hi In my webgrid I have three columns namely “Type” and “Category” and “code” .But while inserting new record I will not enter “Code” Value since it is automatically generated. When I click the AddNew linkbutton,a new row should be created with two textboxes and one Save Button at the footer of the webgrid. I have created the AddNew link...
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7618
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6287
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3657
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
946
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.