Skip to main content
Inspiring
February 25, 2009
Answered

Unable to update Access record

  • February 25, 2009
  • 1 reply
  • 1275 views
Hi,

I have a page that I use to document the issue of a part from the database.
It is suppose to create a record in the table "Issue" documenting the parts reduction (This part works)
It is also suppose to de-increment the part quantity in the table "Main_Table" via an update record server behavior.

That is the part that doesn't work. I have attached the code for this CFM file (sorry, its kinda long...) Any ideas what I am doing wrong here?

Thank You in advance,

Eric

Ps You can view the actual page at: http://devo.dns2go.com/Issue.cfm?PartNumber=1234&Contract=Aries%201X
You will need to log-in. Use Name: User Password: User
    This topic has been closed for replies.
    Correct answer Eric_Dahlenburg
    as long as the FORM contains the data needed for both actions (INSERT
    and UPDATE), you can insert/update that data into as many tables in as
    many databases as you want.

    from your code & explanations it looks like you want to:
    1) UPDATE a record in Table A if the form's action is update ()
    2) INSERT a new record into Table B and UPDATE existing record in Table
    A if the form's action is update ()

    based on the above, your form's action code should look something like:

    <!--- form's action is UPDATE --->
    <cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
    <cfif IsDefined("FORM.MM_UpdateRecord") AND FORM.MM_UpdateRecord EQ
    "Issue_Frm">
    <!--- just doing update --->
    <cfquery datasource="Parts" username="admin" password="dallas">
    UPDATE Main_Table
    SET ...
    WHERE ...
    </cfquery>
    <cflocation url="index.cfm"><cfabort>
    </cfif>
    <!--- form's action is INSERT --->
    <cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ
    "Issue_Frm">
    <!--- insert record into Issues table ... --->
    <cfquery datasource="Parts" username="admin" password="dallas">
    INSERT INTO Issue (Part_Number, "Date", User_Name, WAD, Contract,
    NEMS_Tag)
    VALUES (...)
    </cfquery>
    <!--- ... AND update the Main_Table table --->
    <cfquery datasource="Parts" username="admin" password="dallas">
    UPDATE Main_Table
    SET ...
    WHERE ...
    </cfquery>
    <cflocation url="index.cfm"><cfabort>
    </cfif>


    hth

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/

    Thank You so much for the help. For the basis of other viewing this thread, I have attached the working code. When the submit button is active, data is updated to the Issue table and a new record is written to the Main_Table table.

    Thanks,

    Eric

    1 reply

    Inspiring
    February 25, 2009
    your INSERT query is inside this <cfif> block:

    <cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ
    "Issue_frm">

    while your UPDATE query is inside a different <cfif>:

    <cfif IsDefined("FORM.MM_UpdateRecord") AND FORM.MM_UpdateRecord EQ
    "Issue_frm">

    do you have BOTH MM_InsertRecord AND MM_UpdateRecord fields defined in
    your form? and they both have "Issue_frm" values?

    if the above is not an issue - do you get any errors on execution of
    your UPDATE query or does it just not execute?

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
    February 25, 2009
    I'm not sure, but a few points to make would be:

    1) Can't login to your application, it's LOCALHOST!
    2) Why on Earth do ou set a variable three times? e.g:

    <cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
    <cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
    <cfset CurrentPage=GetFileFromPath(GetTemplatePath())>

    Mikey.
    Inspiring
    February 25, 2009
    Thanks for the reply...

    I looks like left over artifacts from using the Dreamweaver front-end. I have corrected
    that problem. As for logging in, Here is the correct URL: http://devo.dns2go.com/Issue.cfm?PartNumber=1234&Contract=Aries%201X Sorry about that !

    As for the update problem, it looks like Azadi spotted it, more on the reply to his post...