?
Solved

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

Posted on 2014-02-19
2
Medium Priority
?
294 Views
Last Modified: 2014-02-19
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
Comment
Question by:SteveL13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 52

Accepted Solution

by:
Rgonzo1971 earned 2000 total points
ID: 39870915
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
 

Author Comment

by:SteveL13
ID: 39870956
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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question