473,806 Members | 2,782 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

The primary key wont save in the table when i set the default value of the date

115 New Member
Hi I have a form that contains 2 text boxes and a subform contain the Invoice details.
the 1st text box is txtInvoice and its bound to Invoice_number in the invoice table , it's an auto-number. and the 2nd text box is the txtDate it's bound to the Invoice date in the Invoice table.
the subform is related to the main form by the Invoice number (txtInvoice).
The problem is when i set the default value of the txtDate as the sysdate (=date()) , each record of the invoice detail will be saved in the Invoice_detail table without the txtInvoice (without the Invoice number!!).
And in the table Invoice the record will not be saved .
But if i don't put the default value of the txtDate= date()
all the records will save correctly in both tables , with the Invoice number .
Did any one know why ??
Aug 15 '10 #1
11 2169
FishVal
2,653 Recognized Expert Specialist
The obvious reason is that no record has been created in main form and thus no record has been saved into Invoice table.
Aug 15 '10 #2
hannoudw
115 New Member
But it's a bound text box and it must save automatically !!
Aug 15 '10 #3
FishVal
2,653 Recognized Expert Specialist
It won't be saved until you make change to any field of a record. Since autonumber field is not editable and date field already "shows" right value I guess no changes are made and no record is being created.
Aug 15 '10 #4
hannoudw
115 New Member
So what can i do in this situation?
I just want to when i open the form to not fill the date , but i want it to be saved in the database ! how can i do it? should i keep the default value of the date or what?
Aug 15 '10 #5
munkee
374 Contributor
Edit: ignore this post im totally confused
Aug 15 '10 #6
hannoudw
115 New Member
what do you mean by that ??
Aug 15 '10 #7
mshmyob
904 Recognized Expert Contributor
Fish is correct that when using an autonumber you need to actually make a change to a field before the autonumber is commited.

I am curious about your table design between tblInvoice and tblDetails. Could you show us the table design for these two tables, then we may be able to help further.

Also my 2 cents on using an autonumber as your invoice number for an invoicing app: That is a big no no. All invoices MUST be accountable, for audit purposes and that will be impossible using an autonumber. ie: All invoice numbers must be sequential with no missing numbers. Since this is almost impossible with autonumbers you should consider using a system that either allows manual input of invoice numbers with coded sequential checking or an automatic coded system that increments to the next available invoice number.

cheers,
Aug 15 '10 #8
hannoudw
115 New Member
Yes You got a point .
Invoice (Invoice_Num, Invoice_Date, TotalPrice_Befo re_Discount, Total_Paid, Total_Discount)
Invoice_Details (Invoice_Detail_ num, Article, size, Invoice_Num, quantity, price, Discount, Location)
Aug 15 '10 #9
mshmyob
904 Recognized Expert Contributor
Looks fine assuming Invoice_Detail_ Num is an autonumber.

So your question has been answered by Fish and I would still suggest you stop using an autonumber for the Invoice Number.

Oh an as I pointed out in another post the word "Size" is a reserved key word and should not be used for a field name. Remember to prefix ALL field names with an 3 character designation indicating the data type of the field.

I also notice you are storing totals in your invoice table - that is also not recommended.

cheers,
Aug 15 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3465
by: Ian D | last post by:
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)
2
1813
by: hyphen | last post by:
I have set up two date fields in a table: 1stpromisedDate and CurentPromisedDate The first field is to record the 1st promised delivery date of a supplier and the second is to record the current promised ate from a supplier. In an ideal world these two dates will always be the same, but in reality the delivery date will change. Therefore I want to set the currentpromisedate to default to the 1stPromiseDate value. I need
5
1522
by: DSmith | last post by:
Is it possible to make whatever is inputted the default value of a field until a different value is inputted? Thanks in advance!
12
13925
by: Emi Lu | last post by:
Hello all, I have a question about "date" & "timestamp" types in PostgreSQL. I want to setup the default value '0000-00-00' and "0000-00-00 00:00:00" for them. However, it seems that PostgreSQL does not support it. Could someone helps me please? The example table: T1 (col1 varchar(7) not null,
5
3056
by: Øyvind Isaksen | last post by:
I have a page with an optional integer-field, and one asp:calendar control. I use a stored procedure to save the data in SQL Server. When all fields contains data, the code works great! But if the user dont fill in the optional "price-field" (integer value), or if the user dont choose a date in the asp:calendar control, I get the message "Input string was not in a correct format". How do I save "Null" value if the price-field is blank,...
3
13669
by: binder | last post by:
I am designing a new table with a few columns that may or may not have a value on each row that is inserted. What issues determine whether to allow a NULL value to be inserted for that column or define a default value to be used? I want to think through the repercussions of this decision before I get into production.
3
25756
by: zufie | last post by:
I want to use SQL code to Create a Table & Provide a Default Value for Each Column. Here is the code I am using: CREATE TABLE customer (First_Name char(50), Last_Name char(50), Address char(50) default 'Unknown', City char(50) default 'Mumbai',
4
2050
by: rczuba | last post by:
Problem: Creating a Default Value for a field in a subform when a field in the subform & form match. I'm trying to create a payroll database for a small home business that I have that has had (and hopefully will continue to have) lots of growth. I have created a Transaction table to hold the hours, date, location of work (as the employees work at various locations), pay rate, and employee id. the employee id field has a one-to-many...
2
5253
by: ZEHAVISHUL | last post by:
I create table with default value, How can I show the default value. desc'TABLE' doesn't show the defualt value. thank zehava
4
10821
by: billa856 | last post by:
Hi, I want to know how can we set the value of Textbox = value of field in table when we select a value form combobx. example i have a table customer CID CNAME CSALARY 1 Billa $5500
0
9719
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10371
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10373
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9192
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7650
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3852
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3010
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.