Results 1 to 4 of 4
  1. #1
    siema24 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2017
    Posts
    22

    Changing a field value based on another field update value

    Hi,


    I'm wondering how to change field value depending on another fields falue.
    Within one form a have for example: service ID which is a contains a string that should be a combination of strings from two seperate fields: customer ID and service type. So, if my customer AAA has service BB, then in this case service ID should be AAABB.
    User should be able to type service ID by hisself but I want to have it changed due to service type change (when user changes service type from BB to CC, then service ID should be AAACC).
    Do you guys know how to do it with Virtual Basic code? Should I know some kind of a function as ServiceType "after update event" that allowes me getting char from a string based on it's index?
    Some kind of a line: Me.ServiceID.Value(4) = "C" and Me.ServiceID.Value(5)="C" ? Thanks in advance! : )

  2. #2
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Since serviceId seems to be flexible why not have it calculated in a query as me.customerID & "/" & me.serviceType

    You could certainly have a function which took the serviceId and produced two "variable", customerID and servicetype.


    Sent from my iPhone using Tapatalk

  3. #3
    siema24 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2017
    Posts
    22
    Hi, you're right it wokrks almost right however it chnges service ID just for one service. If, for example one customer has three services then I want to get all three of them changed (customer form is a "parent" form, and "service" form is a child form). Do you know how to modify my VBO code to get all serviced that belong to certain customer changed?

  4. #4
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    You could use an update query to update all values in the table where customerID = 2354 setting service type to "ccc"


    Sent from my iPhone using Tapatalk

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

Similar Threads

  1. Replies: 2
    Last Post: 12-20-2016, 08:55 AM
  2. Replies: 0
    Last Post: 06-17-2016, 08:56 AM
  3. Replies: 3
    Last Post: 01-09-2015, 05:48 PM
  4. Replies: 2
    Last Post: 01-31-2013, 07:44 PM
  5. Replies: 1
    Last Post: 08-31-2011, 04:03 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