Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HI, I have NOT been able to get

Status
Not open for further replies.

rossno

Programmer
Feb 8, 2002
46
US
HI,

I have NOT been able to get "autonumber" to work with the ACCESS 2000 database when using SQL when the table is defined as:

CONF_ID autonumber (Indexed, No Duplicates)
FLD_2 text
FLD_3 text

INSERT into JUNKTABLE values ('Foo1', 'Foo2');

ERR: Number of query values and destination fields are not the same.

ACCESS will insert when I supply a dummy value for the autonumber,
INSERT into JUNKTABLE values (2, 'Foo1', 'Foo2');

but that value does not increment. NUTS.

I have searched online, but not found a direct answer to this problem.

Any ideas?

Thanks,
Norm
 
I think this does it:

INSERT into JUNKTABLE (FLD_2, FLD_3) values ('Foo1', 'Foo2');

That's just off the top of my head, I think I have the syntax right...hope that helps.

Kevin
 
Yup, that worked.

I was trying to be lazy by not specifying the table column names, but that doesn't work in ACCESS when using autonumber feature. I tried to keep my original post to a braindead example. The real ASP insert statement looks more like:

SQLcmd = " INSERT INTO RESERVATION "&_
" (CONFIRMATION_DATE, OWNER_ID, CONTRACT_ID, RENTER_ID, USE_TYPE, YEAR, WEEK_NUMBER, "&_
" RESERVE_IN, RESERVE_OUT, CHECK_IN, CHECK_OUT, UNIT_NUMBER, GUEST_TALLY, STATUS, COMMENT) "&_
" values ( " &_
"Date(), " &_
Session("p_owner_id") & ", "&_
Session("p_contract_id") & ", "&_
"001, "&_
"'NORMAL', "&_
Request.form("p_year") & ", "&_
Request.form("p_week_number") & " ,"&_
" CDATE( " & Request.form("p_reserveInDate") & "), "&_
" CDATE(DATEADD('d', 7, " & Request.form("p_reserveInDate") & ")), "&_
"null, "&_
"null, "&_
Request.form("p_unit_number") & " ,"&_
" 99, "&_
"'UNKNOWN', "&_
"'my comment');"


Thanks Kevin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top