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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autonumber

Status
Not open for further replies.

mmchenney

Technical User
May 16, 2001
16
0
0
US
In Dreamweaver Ultrdev 4, I have created a DSN connection to an Access Database. I am able to retrieve records based on specific regions. My question is can I create an "Insert form" and using the first data field labeled "ID" trigger an autonumber (like access does) in my "Insert form". If I can't is there another way to produce the same results?

Molly

 
Well, if you are wanting it to be equivalent to what you will be INSERTing into the database, then you could first run this query on the db:

SELECT MAX(id) FROM tableName

Get that number, and add 1 (or whatever your incrementer is) to the number and stick that in the form --

But my question is why you would really need to do this... In most cases, the user doesn't really need to see this information unless they are updating a database, in which case the number has already been generated and you can just display it -- See what I mean??? If I go join a health club or something, then do I really need to know what my ID# is BEFORE I sign up, or would it be acceptable for me to only know this number after the paperwork has been submitted and processed??

Just some thoughts -- maybe I'm off base. You could use the method above to simulate the autoNumber thing, though.

hope it helps! :)
Paul Prewett
 
When I try and take the ID field out of the UD insert form I get the following error:


Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] You tried to assign the Null value to a variable that is not a Variant data type.

/UCSDEV/PBX/ASPCode/TMPb5yj5dqla9.asp, line 90
out the ID field all together I get the following error:

I am trying your other suggestion right now.

Molly

 
Ahh -- I was assuming that the field you were performing the INSERT on was an autoNumber --

If you do turn on the autonumber option on that field, then you won't have to explicitly INSERT a value for it -- when you add a record, the db will automatically increment and INSERT one for you.

The other should work, though.

:)
Paul Prewett
 
The autonumber field is turned on in the Access Database. However, I am still getting the error message that I mentioned previously. I tried your other suggestion with no luck.

Molly
 
Ok, what was the code you used to retrieve the next possible autoNumber value from the database, and what was the error message that it produced?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top