473,396 Members | 1,773 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,396 software developers and data experts.

involved question about default value from a control

Firstly apologies for the convoluted question. I found this problem whilst
building a larger database. I've distilled it down to as small as possible
and can send a 200k example to anyone who has the time to have a play.
Am I doing something silly or is this an Access problem (or other)?

Access 2000

3 tables
tblID contains ID (autonumber), Data (text)
tbl1 contains ID (Number, default = nothing, Primary Key), bool1 (yes/no)
tbl2 contains ID (Number, default = nothing, Primary Key), bool2 (yes/no)

1 Query
SELECT tblID.*, tbl2.*, tbl1.*
FROM (tblID LEFT JOIN tbl2 ON [tblID].[ID]=[tbl2].[ID]) LEFT JOIN tbl1 ON
[tblID].[ID]=[tbl1].[ID];

2 forms based on this query:
FormOK - Field list used to drag and drop: tblID.ID, Data, bool1, bool2
(Default Value =False)

Allows data to be entered fine.

FormNoGo
Same as formOK but with bool1 Default Value =False as well.

Attempting to add a new record gives:

"Index or Primary Key cannot contain a Null Value"

I can see from the form that the ID field isn't null - it's autonumbering as
expected when text is entered in the data textBox.
I don't usually use bound forms so maybe I've taken the wrong approach
entirely.
Anyone shed any light?

Ian D

- return address spamtrapped but working if you do the obvious
Nov 12 '05 #1
3 3447
The way you have it set up, you have to enter information into Data, then
Bool2, then Bool1 for it to work. That way Access will have an ID number to
pass to the next linked table in the line. If you enter the data out of
sequence, it won't work. So, on your form where Bool1 has a default of
False, if you put a value in for Bool2 (true or false instead of the default
of Null) then it will work.

--
Wayne Morgan
Microsoft Access MVP
"Ian D" <de*************@btopenworld.com.andthis> wrote in message
news:bp**********@hercules.btinternet.com...
Firstly apologies for the convoluted question. I found this problem whilst
building a larger database. I've distilled it down to as small as possible
and can send a 200k example to anyone who has the time to have a play.
Am I doing something silly or is this an Access problem (or other)?

Access 2000

3 tables
tblID contains ID (autonumber), Data (text)
tbl1 contains ID (Number, default = nothing, Primary Key), bool1 (yes/no)
tbl2 contains ID (Number, default = nothing, Primary Key), bool2 (yes/no)

1 Query
SELECT tblID.*, tbl2.*, tbl1.*
FROM (tblID LEFT JOIN tbl2 ON [tblID].[ID]=[tbl2].[ID]) LEFT JOIN tbl1 ON
[tblID].[ID]=[tbl1].[ID];

2 forms based on this query:
FormOK - Field list used to drag and drop: tblID.ID, Data, bool1, bool2
(Default Value =False)

Allows data to be entered fine.

FormNoGo
Same as formOK but with bool1 Default Value =False as well.

Attempting to add a new record gives:

"Index or Primary Key cannot contain a Null Value"

I can see from the form that the ID field isn't null - it's autonumbering as expected when text is entered in the data textBox.
I don't usually use bound forms so maybe I've taken the wrong approach
entirely.
Anyone shed any light?

Ian D

- return address spamtrapped but working if you do the obvious

Nov 12 '05 #2
"Wayne Morgan" <co***************************@hotmail.com> wrote in message
news:ya******************@newssvr32.news.prodigy.c om...
The way you have it set up, you have to enter information into Data, then
Bool2, then Bool1 for it to work. That way Access will have an ID number to pass to the next linked table in the line. If you enter the data out of
sequence, it won't work. So, on your form where Bool1 has a default of
False, if you put a value in for Bool2 (true or false instead of the default of Null) then it will work.

--
Wayne Morgan
Microsoft Access MVP


Thanks for taking the time to reply Wayne

I agree that tblID is the 'master' table so Data has to be entered first.
What I think I've found is that Access can't pass more than 1 default value.
I've made 3 similar forms which show all 3 ID fields:
frmNodefault (both bools unset) - This sets tblID.ID when data is entered
and the ID for either bool table when the checkboxes are clicked.
frm1default (bool1 = True) - sets tblID.ID and tbl1.ID as soon as data is
entered. Otherwise works as above.
frm2defaults (bool1 =True, bool2 =True) - sets tblID.ID and tbl2.ID as above
but *tbl1.ID never gets set* - which gives my original error.

This looks like a problem with Access to me. I've tried it on 2 machines
with the same result. Can you confirm or deny my findings? I can send you
the db if that helps (17k zipped).

regards

Ian D
Nov 12 '05 #3
You are correct. If you want to do this, you will probably need to fill in
the ID field of the other bool table using code in the form's BeforeInsert
event.

--
Wayne Morgan
MS Access MVP
"Ian D" <de*************@btopenworld.com.andthis> wrote in message
news:bq**********@titan.btinternet.com...
"Wayne Morgan" <co***************************@hotmail.com> wrote in message news:ya******************@newssvr32.news.prodigy.c om...
The way you have it set up, you have to enter information into Data, then Bool2, then Bool1 for it to work. That way Access will have an ID number to
pass to the next linked table in the line. If you enter the data out of
sequence, it won't work. So, on your form where Bool1 has a default of
False, if you put a value in for Bool2 (true or false instead of the

default
of Null) then it will work.

--
Wayne Morgan
Microsoft Access MVP


Thanks for taking the time to reply Wayne

I agree that tblID is the 'master' table so Data has to be entered first.
What I think I've found is that Access can't pass more than 1 default

value. I've made 3 similar forms which show all 3 ID fields:
frmNodefault (both bools unset) - This sets tblID.ID when data is entered
and the ID for either bool table when the checkboxes are clicked.
frm1default (bool1 = True) - sets tblID.ID and tbl1.ID as soon as data is
entered. Otherwise works as above.
frm2defaults (bool1 =True, bool2 =True) - sets tblID.ID and tbl2.ID as above but *tbl1.ID never gets set* - which gives my original error.

This looks like a problem with Access to me. I've tried it on 2 machines
with the same result. Can you confirm or deny my findings? I can send you
the db if that helps (17k zipped).

regards

Ian D

Nov 12 '05 #4

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

Similar topics

1
by: Bruce Rusk | last post by:
I've just started using Stephen Lebans' RTF2 control in a database, linked to a Memo field, and am finding it extremely useful (incidentally, in ACC2002 I'm using the class and withevents rather...
2
by: Terry Bickle | last post by:
Please forgive me for using the wrong term here or there. I'm an old Excel 4 macro guy who didn't convert to VB and I'm tinkering with an Access 2000 DB. I'm sure there is a simple Access 101...
3
by: countd4 | last post by:
I have built a working user control. However, to make it work, I always have to set certian properties using the properties sheet for the control when using it on other forms. I want to be able to...
1
by: WhiskyRomeo | last post by:
Since I can't get answer from the author, can someone address this? In this article . . . http://msdn.microsoft.com/msdnmag/issues/04/05/DataPoints/default.aspx In the "The Transaction and...
4
by: Dennis | last post by:
I am trying to set the default design proerties in a control I have derived from the Panel Class. I thought I'd found how to do it from the MSDN but the following line doesn't work: Inherits...
6
by: dbuchanan | last post by:
Hello, Is this a bug? Is there some kind of work around? I want to add default values for a few columns in my datagridview I found the "DefaultValuesNeeded" event for the datagridview I...
0
by: danielclark | last post by:
Hello, Here's my scenario: I have a simple contact form set up where the user can choose how they wish to be contacted from a list of options presented in a Select box (DropDownList)....
1
by: thermate | last post by:
http://www.latimes.com/news/nationworld/nation/la-na-libby26jan26,1,2730931.story?coll=la-headlines-nation Aide testifies Cheney helped effort to discredit Wilson By Richard B. Schmitt, Times...
4
by: helenwheelss | last post by:
Access 2003, using a bound form. I'm seeing rather annoying behaviour when editing data in a control with a default value. It only happens when the form is on a new record. A specific...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.