Happy New Year everyone!

Here's my problem -
I am working on a ColdFusion MX server and with an Access database. There is a field in the database that holds a descriptive ID of the entry (not the autonumber ID). The descriptive ID is 4 letters/dash/3 nunbers (ex. DCWG-003).


I have two queries: Q1 gets the last entry of a certain type (ex. DCWG) and pulls the number portion of that entry (ex. 003) so that it may incremented. After incrementing, I am left with a variable called "newaino" that holds the new descriptive ID (DCWG-004) that will be entered into the database with the new record.

Q2 does the insert of the new record.

Problem: When I get to Q2, it does not recognize newaino. The message I get is "Variable newaino is not defiined". How do I pass newaino to the second query? (A session variable does not seem appropriate.)

I tried with and without the hidden field shown below and got the same error both times. I also tried moving the closing </cfoutput> tag of the first query to the end of the second query, to no avail.

Here is my actual code:

<--- get the last entry of the type specified --->
<cfquery name="AITypeQuery"
         datasource="ipicai_dev"
maxrows=1>
         
SELECT AINo FROM ActionItemsTable WHERE AIType = '#AItype#' ORDER BY AINo DESC
</cfquery>

<--- get the number portion of that entry and increment,
then put the type and dash together with the new number --->

<cfoutput Query="AITypeQuery">
<cfset newnumber=Right(AINo,3)>
<cfset newnumberplus=NumberFormat(IncrementValue(newnumber),000)>

<cfset newaino="">
<cfset newaino= Insert(newnumberplus, newaino, 0)>
<cfset newaino= Insert("-", newaino, 0)>
<cfset newaino= Insert(#AIType#, newaino, 0)>
<input type="hidden" name="newaino" value="#newaino#">
</cfoutput>

<cfquery name="AIQuery"
         datasource="ipicai_dev">
         
INSERT INTO ActionItemsTable(AINo, AIType, AITypeOther, Originator, OriginatorEmail, Actionee, ActioneeEmail, Agency, Initiated, Title, DescriptionofProblemDiscrepancy, TargetCompletion)
VALUES ('#newaino#','#AItype#', '#AItypeother#', '#originator#', '#originatoremail#', '#actionee#', '#actioneeemail#', '#agency#', '#initdate#', '#title#', '#probdesc#', '#targetdate#')

</cfquery>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to