|
-
October 2nd, 2001, 03:51 AM
#1
AutoNumber in access
hi guys,
for my project i created a database in Access 2000.
In one of my tables my primary key is an autonumber.
my table fields are:
StatusNumber -> Autonumber
StatusName -> Text
in my project i wrote a statement that insert a new StatusName but i get an error becouze it needs me to send also a new StatusNumber.
why does the AutoNumber field need me to give him a number? how can i avoid that?
thanks,
ohad.
-
October 2nd, 2001, 04:44 AM
#2
Re: AutoNumber in access
When iserting data using a SQL statement, you can specify which column the data need to go in. I assume the table is called tblStatus
' This will insert the first value in the first field, the second in the second field
INSERT INTO tblStatus VALUES(5,"Sometext")
' This will insert "SomeText" into StatusName, and 5 into StatusNumber
INSERT INTO tblStatus (StatusName, StatusNumber) VALUES("SomeText",5)
' both statements will fail, because statusnumber is autonumber, therefore, we omit it
INSERT INTO tblStatus (StatusName) VALUES("SomeText")
Tom Cannaerts
[email protected]
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|