Results 1 to 7 of 7
  1. #1
    wubbit is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    24

    Help with adding a field.value to another field.value

    I have a client who needs to be able to tweak some entries that are his "standard" answers automatically.
    For example:
    in table INCLUDES I have column MACRO which contains "We will complete the job within considerable time and adhere to {COMPANY NAME}'s policies and standards...."


    He would like the database to replace the {COMPANY NAME} automatically from the table CUSTOMERS. I am not able to figure this out, been about four years since I had to use Access (MySQL is my choice, his was Access).

    Any help to point me in some direction would be greatly appreciated!

    Thanks in advance.

  2. #2
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    Code:
    SELECT
      Replace([INCLUDES].[MACRO], "{COMPANY NAME}", [CUSTOMERS].[COMPANY NAME]) AS [CUSTMACRO]
    FROM 
      [INCLUDES]
    INNER JOIN
      [CUSTOMERS]
      ON
        [INCLUDES].[CUSTOMER ID] = [CUSTOMERS].[ID]
    WHERE
      [CUSTOMERS].[ID] = 1;
    Assuming your INCLUDES and CUSTOMERS Tables are linked by the customer ID, the above Query would return a single field called CUSTMACRO with "{COMPANY NAME}" replaced with the actual company's name for Customer ID 1.

  3. #3
    wubbit is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    24
    Thanks for the assistance, I am going to shoot for a little less complicated. I have a query that pulls all the fields I need to make this happen, but need to generate a If, Then clause to replace the different text that is modified by the user. I think that it can be done, but should this be generated as a Macro of on the forms and reports in the textboxes? Like I said it has been quite some time since I had to use Access.
    I was looking into using this clause for the replace also, it keeps giving an error though.

    =Replace([Macros_QUR].[Includes]![macro_part1],"{COMPANY NAME}",[Macros_QUR].[Customers]![company_name])

    Thanks again for the reply, and any help on this new item

  4. #4
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    I understand. It took me forever to really understand SQL enough to really figure out JOINs and SubQueries. I'll tell ya though, they're really handy once you figure 'em out!

    As for your Code there, is "Macros_QUR" the name of your database? Or is it a Form/Report field? Assuming "Includes" and "Customers" are the names of your tables and "macro_part1" and "company_name" are fields, then your syntax should be more like this:

    Code:
    =Replace([Includes].[macro_part1], "{COMPANY NAME}", [Customers].[company_name])
    You shouldn't have to include the DB name itself.

  5. #5
    wubbit is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    24
    Macros_QUR is the query that is populating the form and reports. I thought that it had to be called when using a query...

  6. #6
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    If the Query is set up as the Form's Record Source, then you don't need to use the Query name. And if it's not, you may want to see if you can modify your Record Source Query to provide the company_name and macro_part1 fields so you can reference them easier.

  7. #7
    wubbit is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    24
    Thanks! That really helped me understand this more. I got it to work finally. I guess I over thought the whole thing again.

    Thanks for the assistance!

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

Similar Threads

  1. Replies: 2
    Last Post: 03-30-2012, 07:39 AM
  2. Adding values to another field
    By GraemeG in forum Queries
    Replies: 0
    Last Post: 04-07-2011, 09:56 AM
  3. Replies: 10
    Last Post: 04-21-2010, 01:16 PM
  4. Adding a Field Name
    By jackthedog in forum Reports
    Replies: 1
    Last Post: 07-04-2009, 08:18 AM
  5. Adding pdf to a field
    By Hannu in forum Access
    Replies: 3
    Last Post: 05-27-2009, 07:08 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