Results 1 to 4 of 4
  1. #1
    FIZGIG is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2020
    Posts
    15

    If on enter, auto fill from another field, otherwise enter new data

    Newbie(ish) question:

    The title is the what I'm trying to do. This is what I have done that works BUT if anyone accidentally clicks on, tabs through, or enters the field, it puts in the data from the related field. I want it to save any new data and not allow any accidental changes.

    Private Sub CASE_COST_Enter()


    [CASE_COST] = [CASE_COST2]
    End Sub

    Case_Cost is a field in a new PO form. Case_cost2 is from a query that lists last purchase price.
    Any suggestions?
    TIA
    CS

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Probably not the event I'd use, but does this work?

    Code:
    If Me.NewRecord Then
      [CASE_COST] = [CASE_COST2]
    End If
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    FIZGIG is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2020
    Posts
    15
    Thanks for the reply. No, it didn't work. What event would you use?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Perhaps

    Code:
    If Len(Me.[CASE_COST] & vbNullString) = 0 Then
      [CASE_COST] = [CASE_COST2]
    End If
    The enter event requires the user to "enter" that control. I don't have the big picture of what you're doing, but I'd prefer an event that didn't require the user to do anything in any particular order.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 1
    Last Post: 09-01-2017, 10:28 AM
  2. Replies: 3
    Last Post: 05-15-2017, 06:33 PM
  3. Field auto enter new line on enter event
    By Ruegen in forum Forms
    Replies: 3
    Last Post: 09-17-2013, 09:00 PM
  4. Form auto enter field on new record click
    By Traceyann in forum Forms
    Replies: 3
    Last Post: 08-18-2012, 08:39 AM
  5. Replies: 6
    Last Post: 04-27-2012, 01:31 PM

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