Results 1 to 5 of 5
  1. #1
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232

    after update vb code

    I have the following two codes after update I think I should have one code that would be cash true or else financed true so they will work together
    they have a Yes/No field for each ( cash yes no and financed yes no) I have attached the code to each one.
    I tired to have a value combo box with the two listed (financed and cash ) but could not get the code to work by selecting the value from the combo box.
    If I could do a combo box it would be better just could never figure it out.

    Thanks Angie

    Private Sub Cash_Or_Check_AfterUpdate()
    CASH = True
    Me.Total_Cost = Cash_Price


    End Sub


    Private Sub Financed_AfterUpdate()
    Financed = True
    Me.Total_Cost = Financed_Price

    End Sub

  2. #2
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Not enough info for me at least, to help you get what you originally wanted. Post what you tried, and be specific about what these names are (you seem to have 3 or 4 controls in each piece but I have no idea what they are or are supposed to reflect). More info needed about your combo box. Is it bound? What's the row source? Does it have more than one column? Be clear about what you have and what you want to achieve.
    Afterthought: Nothing wrong with what you have if it works. Sometimes you just have enough difference between similar events for different controls that you just do it the way you have it. To combine them in a way and still have separate checkboxes would require a separate procedure. If you had one checkbox (yes for cash no for finance) that would be a different story.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232
    Maybe this would work better different way of achieving the same thing but maybe better way of doing it.

    I have the following on a form
    text box named [financed price] format currency
    text box name [cash price] format currency
    Combo Box named [payment type] which is a value list with two selections (financed) and (cash or check)
    text box named [total cost] format currency
    I would like if the combo box value is "financed" then the data entered in the text box [financed price] will show in the total cost text box
    if the combo box value is "cash or check" then the data entered in the text box [cash price] will show in the total cost text box

  4. #4
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    You really must Google Access naming conventions - it is very bad form to have spaces in the names of things. While you're at it, research reserved words because that will be the next trap you fall into. The following should work but is untested. You will note I have used a more reliable name for the controls, and have preceded them with some letters that denote their type (as per suggestion one above). If you do not like them, I leave it to you to transpose the relationships between what I wrote and what you have. Either way, the names have to match what you have in your db so you'll be changing what I wrote or your control names.

    Code:
    Private Sub cmbPayType_AfterUpdate
    If me.cmbPayType = "financed" then
    me.txtTotal = NZ(me.txtFinancePrice,0)
    else
    me.txtTotal = NZ(me.txtCashPrice,0)
    End If
    Last edited by Micron; 04-16-2016 at 06:03 PM. Reason: spellin
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232
    Thanks Micron I changed a few things but it is working this is what I ended up with, also I will google access naming conventions. Thanks for the advise about spaces in the names of things I will work on correcting these issues.
    Thanks again

    Private Sub Payment_Type_AfterUpdate()
    If Me.Payment_Type = "financed" Then
    Me.Total_Cost = Nz(Me.Financed_Price, 0)
    Else
    Me.Total_Cost = Nz(Me.Cash_Price, 0)
    End If
    End Sub

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

Similar Threads

  1. update VBA 2.0 code in forms into access 7.0 code
    By toughwg in forum Programming
    Replies: 1
    Last Post: 12-08-2015, 11:40 AM
  2. Hello Everyone!! UPDATE query VBA Code
    By Jllera in forum Programming
    Replies: 12
    Last Post: 03-06-2015, 08:46 PM
  3. Replies: 2
    Last Post: 06-28-2013, 12:58 PM
  4. Help with form Update Code
    By awhit22 in forum Forms
    Replies: 2
    Last Post: 05-11-2011, 01:32 PM
  5. Before Update code
    By jms in forum Forms
    Replies: 1
    Last Post: 03-10-2011, 11:28 AM

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