SunQuest
           ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old January 13th, 2004, 04:45 PM
sheri sheri is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 4 sheri User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 21 sec
Reputation Power: 0
Talking ColdFusion, Using Access DB

Hello There
I am trying to create a project number that does appear on my submittal form and it consists of 3 parts(i.e. 4 SE-123)the 1st digit represent the year the next 2 letter are representing the department and the last 3 digits are ID autonumber from the table. The project number will be used in the search page and also to refer to corresponding word doc. I tried these codes and I get the error message. Please tell me what exactly my problem is.

<cfquery name="MaximumID" datasource="Capital2Reqs">
SELECT MAX (ID) FROM Capital2_Inputs
</cfquery>

<cfquery name="ProjectNumber" datasource="Capital2Reqs">
SELECT (4 + '#Form.Departments#' + '-' + Max (ID)) AS Project_No FROM Capital2_Inputs
</cfquery>

<CFQUERY NAME="UserInsert" DATASOURCE="Capital2Reqs" >
INSERT INTO Capital2_Inputs (Project_No,Div_Priority,Status,Just_Detail,Divisi
on,Departments,Org_Number,Org_Name,Director)
VALUES ('#Project_No#','#Form.Div_Priority#','#Form.Status#','#Just_Detail#','#Form.Division#','#Form.Depar tments#','#Form.Org_Number#','#Form.Org_Name#','#Form.Director#');
</CFQUERY>

THE ERROR MESSAGE IS:
ODBC Error Code = 22005 (Error in assignment)
[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
SQL = "SELECT (4 + 'AR' + '-' + Max (ID)) AS Project_No FROM Capital2_Inputs"
Data Source = "CAPITAL2REQS"
The error occurred while processing an element with a general identifier of (CFQUERY), occupying document position (52:1) to (52:56
Thanks
Sheri

Reply With Quote
  #2  
Old January 13th, 2004, 06:11 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,618 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 9 h 44 m 33 sec
Reputation Power: 53
You're trying to concantenate elements of different data types. You'll need to play with quote, etc. to get it to work. Maybe something like:

<cfquery name="ProjectNumber" datasource="Capital2Reqs">
SELECT ('4 ' + '#Form.Departments#' + '-' + Max(ID)) AS Project_No FROM Capital2_Inputs
</cfquery>

Also the ID field for which you are selecting the maximum value will also need to be a string I believe. Or are you really trying to insert the value from the first query into the second one? In that case try something like:

<cfquery name="MaximumID" datasource="Capital2Reqs">
SELECT MAX(ID) as maxID FROM Capital2_Inputs
</cfquery>

<cfquery name="ProjectNumber" datasource="Capital2Reqs">
SELECT ('4 ' + '#Form.Departments#' + '-' + '#maximumID.maxID#') AS Project_No FROM Capital2_Inputs
</cfquery>

Reply With Quote
  #3  
Old January 14th, 2004, 05:04 PM
sheri sheri is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 4 sheri User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 21 sec
Reputation Power: 0
CF/ Access DB

Should I make a new table for ID only to make sure the maxID that I pull out is the same as the maxID in the project_No. If I do it with 2 different tables, then I do not need that maximumID query, and I'll be using this query only
<cfquery name="ProjectNumber" datasource="Capital2Reqs">
SELECT ('4 ' + '#Form.Departments#' + '-' + 'max(ID)') AS Project_No FROM Capital2_Inputs
</cfquery>
If I have the ID (autonumber) in 2nd table, then what do I need to change in my code making the project_No.

Thanks
Sheri

Reply With Quote
  #4  
Old January 15th, 2004, 12:24 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,618 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 9 h 44 m 33 sec
Reputation Power: 53
I'm missing the reason why you would need a second table to compare the max id to. If you want to select the highest id field from the captial2_inputs table and use it, you don't need another table. But you do either need a second query to get the max id first, or you need to convert the id to a string before you can use it in the concatenation. This is a guess since I don't have Access to test it on, but maybe something like:

<cfquery name="ProjectNumber" datasource="Capital2Reqs">
SELECT ('4 ' + '#Form.Departments#' + '-' + toString(max(ID))) AS Project_No FROM Capital2_Inputs
</cfquery>

That assumes that access has a toString() function or something similar.

Reply With Quote
  #5  
Old January 15th, 2004, 07:28 PM
sheri sheri is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 4 sheri User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 21 sec
Reputation Power: 0
Talking CF/MS Access

Kiteless
Thanks for your replies. Let me start the questions from the beginning. I do not include any codes because everything I tried I ended with error message. I need to create Project_No and Just_Detail. Both of these fields do not appear in the submittal form, but they will be in the editform and the search page. Project number consistes of 3 parts(i.e. 4SE-123), and Just_Detail should be linked to word document (of detailed justification) for each project number. There should be 2 options for Just_Detail in the the search page 1) EDIT; if there is a word doc already made for that project number, or
2) CREATE if there is none, there should be a blank form that the user can go and fill it out then
The search page should include these( view and edit for project no should be linked to printform and edit form & Create and edit for Justification Detail should be linked to existing and blank word doc form).

Project Number : 12345 View Only Edit Only
Justification Detail : 12345.doc Create Only Edit Only

Would you please tell me what would your approach be to have both of these, also the codes that you would be using.

Thanks a lot,
Sheri

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > ColdFusion, Using Access DB


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway