Results 1 to 3 of 3
  1. #1
    mejia.j88 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Nov 2011
    Location
    california
    Posts
    228

    trouble starting code

    Hi all, and thanks in advance

    I have a form which has three different text boxes, belonging to three different part numbers, call these text boxes "B_partA", "B_partB", "B_partC".

    if we are building partA, the operator will enter the number of 'boats' used to build partA. Same for partB and partC. Each boat has a different value of components in it, 1405, 603, and 202 respectively. These three text boxes go to the same field, but i am not interested in the number of boats, rather the components used.

    for example. In building partA, say i used 4 boats. i would enter 4 into the text box B_partA, but if i look at my table, i woudlnt want to see 4, i would want to see 5620, (4*1405).



    simarly with the rest of the parts.

    QUESTION: i guess my question is, what is the best way to code something like this?

    again, Thank you,
    -j

  2. #2
    mejia.j88 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Nov 2011
    Location
    california
    Posts
    228
    Code:
    Private Function updatevalues()
    If IsNull(Me.txtBoats040) = False Then
    Val (Me.txtBoats040) * Val(1056) + Val(Nz(Me.txtPartials040, 0)) = ![total_leadbonded]
    ElseIf IsNull(Me.txtBoats063) = False Then
    Val (Me.txtBoats063) * Val(527) + Val(Nz(Me.txtPartials063, 0)) = ![total_leadbonded]
    ElseIf IsNull(Me.txtBoats125) = False Then
    Val (Me.txtBoats125) * Val(405) + Val(Nz(Me.txtPartials125, 0)) = ![total_leadbonded]
    End If
    End Function
    that is what i have, but I cant get it to save, i made a new field caleld total_leadbonded, where i want the data to be stored :S

  3. #3
    mejia.j88 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Nov 2011
    Location
    california
    Posts
    228

    Smile

    i solved my own problem:


    Code:
    Private Function updatevalues()
    If IsNull(Me.txtBoats040) = False Then
    Me.TxtTotalLeadbonded = Val(Me.txtBoats040) * Val(1056) + Val(Nz(Me.txtPartials040, 0))
    ElseIf IsNull(Me.txtBoats063) = False Then
    Me.TxtTotalLeadbonded = Val(Me.txtBoats063) * Val(527) + Val(Nz(Me.txtPartials063, 0))
    ElseIf IsNull(Me.txtBoats125) = False Then
    Me.TxtTotalLeadbonded = Val(Me.txtBoats125) * Val(405) + Val(Nz(Me.txtPartials125, 0))
    End If
    End Function
    might be useful for someone.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. trouble with one line of code
    By mejia.j88 in forum Programming
    Replies: 3
    Last Post: 01-25-2012, 10:53 PM
  2. trouble with borrowed code
    By mejia.j88 in forum Programming
    Replies: 1
    Last Post: 01-23-2012, 11:59 PM
  3. trouble starting code
    By mejia.j88 in forum Programming
    Replies: 32
    Last Post: 12-15-2011, 11:57 AM
  4. VB code in Access '07 trouble
    By Pauldk in forum Reports
    Replies: 2
    Last Post: 02-18-2009, 03:59 PM
  5. Code Trouble?
    By briancb2004 in forum Access
    Replies: 0
    Last Post: 10-08-2008, 04:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums