Skip to main content
Inspiring
July 23, 2008
Question

unique id when form is submitted

  • July 23, 2008
  • 5 replies
  • 780 views
I have a form that submits data to an access 2007 database. I am using formfields: Is there a way to create a unique id that gets entered into the database and display it as an registration/confirmation number on the action page? _ THANK YOU

<cfinsert datasource="design2008" tablename="2008RDCRegistratation"
formfields="fullname, Email, County, Title, Phone, Address1, Address2, Payment, CitySTZip, Allergies, Vegetarian,">
This topic has been closed for replies.

5 replies

Inspiring
July 24, 2008
You don't have any criteria in your sql statement, so its going to return all RegisterDates. If you need some tutorials, just google cf beginner tutorials or check out this thread. Also, that book will come in very handy.
rockhikerAuthor
Inspiring
July 24, 2008
I added more to the query and was able to return the id field instead of the date field to use for the registration number. Is that okay to do? I learned a lot here.

Thank you both for your time.
Inspiring
July 24, 2008
You'll know why after you get that book and do all the tutorials.
Inspiring
July 24, 2008
Here is a hint.

<cfquery>
any sql you have permission to run goes here
</cfquery>
Inspiring
July 24, 2008
I've heard good things about the book, Teach Yourself SQL in 10 Minutes by Ben Forta.
rockhikerAuthor
Inspiring
July 24, 2008
Thanks - I will check out the book. I do have some understanding of sql - I just don't quite get the Coldfusion part of where things go and I have had a hard time finding examples for a beginner. I don't just want the code. I want to why it works. -- Thank you

jim
rockhikerAuthor
Inspiring
July 24, 2008
I tried adding a query to retrieve the date that a person registers on. I set the default value in access to Now() so it adds the date when a user submits a registration. I then added a query to retrieve the date. On the action page it retrieves the date but it returns ALL of the dates in the table - see query and output below. - thank you

<cfquery name="register" datasource="design2008">
SELECT RegisterDate FROM 2008RDCRegistratation
</cfquery>

<cfoutput query="register">Your registration number is #RegisterDate#</cfoutput>


OUTPUT:

Your registration number is Your registration number is Your registration number is Your registration number is 2008-07-24 10:20:03.0Your registration number is 2008-07-24 10:21:28.0Your registration number is 2008-07-24 10:22:04.0Your registration number is Your registration number is

Inspiring
July 24, 2008
You can use the CreateUUID function, do a query to make sure it's not already there, and then use it.

Or you can set up an autoincrement numeric field in access, change your cfinsert to a cfquery, and then select it after you insert the record.
rockhikerAuthor
Inspiring
July 24, 2008
I do have an autoincrement field in the access database. I do not understand how to insert a record after changing the cfinsert to a query. Do you know a good reference or tutorial?

Thank you