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
Solved

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

Posted on 2014-02-19
2
290 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
2 Comments
 
LVL 50

Accepted Solution

by:
Rgonzo1971 earned 500 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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

840 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