[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 298
  • Last Modified:

How write new value to a 2nd field using the first three parts of the 1st field

On a form I have a field that for example reads,

"Mountain Picture, 8x10, Matted, Vertical, New York"

Note that there will always be 4 character strings with commas following in every case.

Also on the form is a combobox named cboToLocation which shows column 2 from the underlying query (even though the ID field is in the first column and is bound to the field on the form.  That field might display, for example, "Rockford".

In the after update event of the cboToLocation field I want a field named "New Product", to read "Mountain Picture, 8x10, Matted, Vertical, Rockford"

In other words replace "New York" with "Rockford" in the "New Product" field.

How do I code this?

--Steve
0
SteveL13
Asked:
SteveL13
1 Solution
 
Rgonzo1971Commented:
HI,

I'm not sure to understand

but maybe

strText = "Mountain Picture, 8x10, Matted, Vertical, New York"
strReplacement = "Rockford"
aText = Split(strText, ",")
aText(UBound(aText)) = strReplacement
strText = Join(aText, ",")

Open in new window

Regards
0
 
SteveL13Author Commented:
You understood very well.  Here is the code after I replace with real field names and added a space before the "Rockford" part of the text string...

    strText = Me.txtProductID.Column(1)
    strReplacement = Me.cboToLocation.Column(1)
    aText = Split(strText, ",")
    aText(UBound(aText)) = strReplacement
    strText = Join(aText, ", ")
    Me.txtTransferredProdRef = strText

Thank you!
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now