+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 15

Thread: Field that is a link (rs) and/or text field question

  1. #1
    Barn Legend Rebelle will become famous soon enough Rebelle's Avatar
    Join Date
    Mar 2008
    Posts
    1,522
    Rep Power
    5

    Field that is a link (rs) and/or text field question

    Hi All,

    Ok, I have the following field on my form because if the Item does not have a price (intItem is ItemCost) is not zero then I don't want to allow users to change/update the ItemDescription but it will also be a link to BOMMaster page....but if it is zero they can have a text field to input a ItemDescription, these will not have BOMMasters....

    Code:
    <TD align=right>
    <%
    If intItem <> 0 then
    %>
    <a href="//testserver/application/BOMMaster.asp?ItemID=<%=rs("ItemID")%>" target="_blank"><%=rs("ItemDesc")%></a> &nbsp;</TD>
    <%
    else
    %>
    <INPUT CLASS="clrBg" type="text" name="InputItemDesc" size="30" maxlength="4" value="<%=rs("ItemDesc")%>"</TD> <%
    End If
    %>
    </TD>
    

    Question: I added "InputDescription" field to my tblDetails, how can I update this field from the above code? since I dont have a (Name="InputItemDesc") on the ones that do have a itemcost? Right now "Desc" (rs) is being pulled from another table (tblItem) "ItemDescription".

  2. #2
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    I guess I don't understand your question. To update the field in the database just submit the form using the ItemID to identify the record and then update the data.
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  3. #3
    Barn Legend Rebelle will become famous soon enough Rebelle's Avatar
    Join Date
    Mar 2008
    Posts
    1,522
    Rep Power
    5

    Hiya JMH,

    But my form has multiple items, example:
    The underlined ones below are the ones with a itemcost > 0

    Code:
    Category1
    -Group1
    ItemDescription1-Q1-Q2-Q3-Q4-DistrictCost-ItemCost
    ItemDescription2-Q1-Q2-Q3-Q4-DistrictCost-ItemCost
    ItemDescription3-Q1-Q2-Q3-Q4-DistrictCost-ItemCost
    
    When I do my update, I will look at RegionID,DistrictID,ItemID.....will that still work like that?

  4. #4
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    Each of those items should have an ID in the database. You will simply have to loop through them and run an update query using that ID to update the data.

    Instead of InputItemDesc, call it InputItemDescXX, where XX is the ID. Then, when the form is submit, query the database for that group to pull all of those IDs and if InputItemDescXX = the recordID AND has a data inside, update the query.

    For example:
    Code:
    'The form has been submit
    sql = "SELECT itemID From ItemDesc WHERE groupID = " & Request.Form("groupID")
     
    'Create recordset and execute the query here
    ...
     
    'Loop through the query
    Do While Not rs.BOF And Not rs.EOF
        If Len(Request.Form("InputDesc" & rs("itemID"))) > 0 Then
            sql = "UPDATE ItemDesc SET ItemDesc = '" & Request.Form("InputDesc" & rs("itemID")) & "' WHERE itemID = " @ rs("itemID")
            
            'Execute update statement
        End If
    rs.MoveNext
    Loop
    
    Make sense?
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  5. #5
    Barn Legend Rebelle will become famous soon enough Rebelle's Avatar
    Join Date
    Mar 2008
    Posts
    1,522
    Rep Power
    5

    Ok, kind of....I think I'm still a little confused by myself dealing with the ones they can change (desc/input cost)....let me give it a try and see how it comes out....Thanks JMH!!! Will keep ya posted on the progress.

  6. #6
    Barn Legend Rebelle will become famous soon enough Rebelle's Avatar
    Join Date
    Mar 2008
    Posts
    1,522
    Rep Power
    5

    Ok, I added something like this but just realized I have another issue....you first go in an if the intItem is 0 then you can enter a price but after I've entered a price what happens if I want to change it...it's no longer 0? Crud, have to rethink this again.

    Code:
    <TD align=right>
    <%
    If intItem <> 0 then
    %>
    <INPUT CLASS="clrBg" type="text" name="InputItemDesc<%response.write(i)%>" size="30" maxlength="4" readonly value='<%=rs("ItemDesc")%>'</TD>
    <%
    else
    %>
    <INPUT CLASS="clrBg" type="text" name="InputItemDesc<%response.write(i)%>" size="30" maxlength="4" value='<%=rs("ItemDesc")%>'</TD>
    <%
    End If
    %>
    
    Last edited by Rebelle; July 14th, 2008 at 10:48 AM. Reason: changed code above.

  7. #7
    Barn Frequenter BLaaaaaaaaaarche will become famous soon enough BLaaaaaaaaaarche will become famous soon enough BLaaaaaaaaaarche's Avatar
    Join Date
    Mar 2008
    Posts
    188
    Rep Power
    5

    Why are you only allowing them to change the price if it is 0? What is the difference?
    "You'll never be as perfect as BLaaaaaaaaarche."

  8. #8
    Barn Legend Rebelle will become famous soon enough Rebelle's Avatar
    Join Date
    Mar 2008
    Posts
    1,522
    Rep Power
    5

    oops...just saw your reply...was in shoutbox.

    i have an Item table where the item desc and cost is stored...some of those items are $0. Those are items that I need to allow to change the Item description and the cost (because desc is something like Misc.). All other items should not be changed.

    so since each district will have its own results, i added a details table which will hold each districts details (items/cost/qtrs, etc.) but I went back and added a location cost field and district input desc field because i need to show any ones they can change the desc/cost as what they change it to.

    but now since the asp code looks to see if the cost is $0....what happens if they have entered a price for a misc item and put $20, they will longer be able to change it.

    should my view contain both the cost from items table and district cost from details table..? would this take care of the issue above?

  9. #9
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    So why are you doing that check in the first place? If they need to be able to edit everything...allow them to. Your logic needs to be rethought. Why even store items in the database if it doesn't have a real value? I would have a table that stores possible items. Then use that and create a relationship with another table that actually stores the data for each district. If you could script a SQL Server database for us and populate it with some values, we could probably show you a better solution.
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  10. #10
    Barn Legend Rebelle will become famous soon enough Rebelle's Avatar
    Join Date
    Mar 2008
    Posts
    1,522
    Rep Power
    5

    Hopefully i did it right.... I've attached the sql tables that I'm using. I created a view but it's not in the attached file, should i script it too? I've got the asp page setup to show all categories, groups, items then it sums each category, then a grand total at the end. just need to work on flow/edit screen (only edit items that are Misc items with $0). All others should stay as assigned in the items table because I will need to somehow show a page with all Regions/Districts combined.

    I'm thinking i'm going to plug in data into the details table for each districts with Null in the qtrs so they can have something to start with....then all they will be doing is editing those same records.
    Attached Files

+ Reply to Thread
Page 1 of 2 1 2 LastLast

Similar Threads

  1. Excel question
    By Rebelle in forum Microsoft Office
    Replies: 11
    Last Post: May 27th, 2008, 08:22 PM
  2. C# database question
    By peebman2000 in forum .NET Development
    Replies: 19
    Last Post: April 21st, 2008, 04:23 PM
  3. Using a field value in an IN(...) clause
    By richyrich in forum MySQL
    Replies: 5
    Last Post: April 13th, 2008, 12:56 PM
  4. Suggestions - ChangedOn field
    By Rebelle in forum ASP Development
    Replies: 7
    Last Post: April 8th, 2008, 03:07 PM
  5. Help with Updating field
    By Rebelle in forum Microsoft Access
    Replies: 5
    Last Post: April 1st, 2008, 07:45 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO