Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    captiangvp is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2021
    Posts
    24

    Saving to 2 cells from one form entry

    I have a project I'm working on and I need to be able to hit save and, for example let's use field 3.


    I need to be able to fill out field 3, then when I hit save it'll save to the table into 2 cells instead of just one.
    Example:
    On the form
    Field 1 - John
    Field 2 - Smith
    Field 3 - city

    On the table
    Location - city
    First name - John
    Last name - Smith
    Location(2) - city

    So is there anyway to hit save on the form and have it save city to both Location and location 2 without having to fill it in twice on a form?

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    Why do you need to save it twice? Goes against everything a db is?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    captiangvp is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2021
    Posts
    24
    So the table is exported as a CVS file that's uploaded to a website builder and it has 2 fields on the website that is exactly the same. Ik I can just add the field to a form and manually input it but was wondering if there's a vba or code that will auto populate it when hitting save

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Yes.

    Me!Location2 = Me!Location

    Might want to use AfterUpdate event of Location.

    Or export a query that calculates Location2: =Location1
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    captiangvp is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2021
    Posts
    24
    Quote Originally Posted by June7 View Post
    Yes.

    Me!Location2 = Me!Location

    Might want to use AfterUpdate event of Location.

    Or export a query that calculates Location2: =Location1
    Omg thank you! Will try this first thing tomorrow!

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Correction, calculation in SQL would look something like:

    SELECT tablename.*, Location AS Location2 FROM tablename;
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    I would be going with the query method?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  8. #8
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,043
    I would definitely go for the query method. I think a query is the best method to calculate new values out of the existing database fields. However, for export purposes I would not use select * . If a new field is added to the table, it's added to the queryresult and the csv output is altered. For export purposes I would always use a syntax like for example:

    select field1, field2, field2 as field3, ect. ... from MyTable where [criteria] order by field1, field2, ...

  9. #9
    captiangvp is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2021
    Posts
    24
    Well.. maybe i'm too stupid, i can't seem to get it to work

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    What do you mean by "can't seem to get it to work"? What doesn't work - query, VBA, export? Error message, wrong result, nothing happens?

    If you want to provide sample db, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    captiangvp is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2021
    Posts
    24
    Quote Originally Posted by June7 View Post
    What do you mean by "can't seem to get it to work"? What doesn't work - query, VBA, export? Error message, wrong result, nothing happens?

    If you want to provide sample db, follow instructions at bottom of my post.
    No matter what I do the text box on the form returns #error

    Wish it were like excel and as simple as vlookup 😅

  12. #12
    captiangvp is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2021
    Posts
    24
    I will provide one when home

  13. #13
    captiangvp is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2021
    Posts
    24
    Quote Originally Posted by June7 View Post
    What do you mean by "can't seem to get it to work"? What doesn't work - query, VBA, export? Error message, wrong result, nothing happens?

    If you want to provide sample db, follow instructions at bottom of my post.
    I think i did it right.
    SO my main goal, is that the "distributor" field on the table "products" needs to reflect exactly what manufacturer is. which i know is redundant but is required for the setup that the website builder has. I know that i can just create a field on the "Products_form" and manually input it or do another drop down. BUT just for automated purposes i'm trying to just get it to either auto copy there, or for a field in the form to auto populate what the manufacturer is and save it to distributor field IF POSSIBLE. If its not possible/easy enough to figure out, no big deal. Thanks for everyone who attempts to help! Its greatly appreciated

    Sample DB.zip

  14. #14
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    I thought we had established that you just need to repeat on the query for the csv
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  15. #15
    captiangvp is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2021
    Posts
    24
    Quote Originally Posted by Welshgasman View Post
    I thought we had established that you just need to repeat on the query for the csv
    yeah forgot to add i have no idea what this part meant. I'm not an access pro as i'm used to doing tons of work in excel, but for this particular project its required for us to use access and i keep getting stomped on it i've messed around with query wizard but i'm not connecting dots here

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 7
    Last Post: 08-05-2020, 11:34 AM
  2. Problem saving a new entry with multiple tabs
    By neilsolaris in forum Forms
    Replies: 31
    Last Post: 05-28-2020, 12:22 PM
  3. Replies: 6
    Last Post: 09-14-2018, 01:47 PM
  4. Form To Table - To Many Cells
    By LOUM in forum Forms
    Replies: 3
    Last Post: 05-03-2012, 02:21 PM
  5. Replies: 23
    Last Post: 02-09-2011, 10:56 AM

Tags for this Thread

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