473,382 Members | 1,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Access, required fields, forms & ODBC

I am working on an Access 2002 database where one of the tables has
five required fields making up the key.

There is a form that is linked to this table which is used for adding
new records.

There is a close button on this form that has the following code in
it's OnClose event:

"DoCmd.close"

When the form is opened, no data entered and then the close button is
clicked - nothing happens.

It used to work fine, until I recently upsized the database into a SQL
Server database and now it's all gone horribly wrong.

If I close the form manually by clicking on the cross, I get this
error:

[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot insert the value
NULL into column 'Product', table
'LeasebookSQL.leasebook_user.leases'; column does not allow nulls.
INSERT fails. (#515) [Microsoft][ODBC SQL Server Driver][SQL Server]
The statement has been terminated. (#3621)

Can anyone please tell me how I can get the form to close without
trying to save the record, especially when no changes have been made
to the data on the form?

Jan 28 '08 #1
1 3000
On Jan 28, 10:48*am, sdavis1970 <simondavis1...@gmail.comwrote:
I am working on an Access 2002 database where one of the tables has
five required fields making up the key.

There is a form that is linked to this table which is used for adding
new records.

There is a close button on this form that has the following code in
it's OnClose event:

"DoCmd.close"

When the form is opened, no data entered and then the close button is
clicked - nothing happens.

It used to work fine, until I recently upsized the database into a SQL
Server database and now it's all gone horribly wrong.

If I close the form manually by clicking on the cross, I get this
error:

[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot insert the value
NULL into column 'Product', table
'LeasebookSQL.leasebook_user.leases'; column does not allow nulls.
INSERT fails. (#515) [Microsoft][ODBC SQL Server Driver][SQL Server]
The statement has been terminated. (#3621)

Can anyone please tell me how I can get the form to close without
trying to save the record, especially when no changes have been made
to the data on the form?
Having DoCmd.Close in the form's OnClose event is redundant. The form
is already closing by the time the OnClose event is occurring.
Putting this in the button's Click event makes more sense.

Something is happening to make that form 'dirty', i.e. something is
making that form think that data has changed and needs to be saved.
Perhaps one or more of the field values are being set in the form's
Load, Open, or Current events or elsewhere in code. To confirm this,
set the Record Selectors property to Yes on that form if isn't set to
that already. When you open the form, if you see a little picture of
a writing pencil instead of a small black triangle in the form's
record selector then you know the record is 'dirty', i.e., data has
changed and the form will attempt to save it upon closing.

To give your users the option of closing the form without saving any
data changes you might want to add a Cancel button with the following
code in it's OnClick event:

Me.Undo
DoCmd.Close

Or alternately you might want to simply ask this question in the close
button's Click event:

If Me.Dirty Then
If MsgBox("Save changes?", vbYesNo) = vbNo Then Me.Undo
End If

DoCmd.Close

You might also want to check to see if the required fields for your
key have been filled in in the form's BeforeUpdate event.

Bruce
Jan 28 '08 #2

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

Similar topics

3
by: Jon Ole Hedne | last post by:
My Access 2002-application need to work with tables from both Oracle and Access. To solve this, I want to run some querys on three views in Oracle and import the results into temporary...
3
by: Gheaci Maschl | last post by:
Hi all! I would like to have your opinion about my problem and my proposal how to solve it: Ingredients: - BTriev database - Crystal Reports - maybe MS Access - Liinos6 (small ERP software)
49
by: Yannick Turgeon | last post by:
Hello, We are in the process of examining our current main application. We have to do some major changes and, in the process, are questionning/validating the use of MS Access as front-end. The...
2
by: monnomiznogoud | last post by:
Ok, my problem is the following: I have very complicated Access 97 databases that link through ODBC to Sybase databases. Now in some of the forms controls I had queries that used as "where...
2
by: egoldthwait | last post by:
I need to convert a 17mb access 2000 db to Oracle and house it in a Citrix farm. The issue: we have never converted an Access Db to Oracle but can probably use Oracle's Workbench to assist with...
1
by: gordon.dtr | last post by:
Hi, Has anyone had this problem ? I am using MySQL ODBC 3.51 Driver, with MS Access 2003 and MySQL 4.1.11 standard log. I created my tables in MS Access, then exported them via ODBC to an...
9
by: Bob Alston | last post by:
I am looking for electronic forms software that would integrate well with MS Access. I have a client for whom I built a client database to replace and update one they had that was obsolete and...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
7
by: robert.waters | last post by:
I have an Access database frontend linked via ODBC to a large (gigabytes) mysql database. I need to view a large amount of data in a a textbox (variable up to 300K), but I receive a 'there isnt...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.