Results 1 to 9 of 9
  1. #1
    DNASok is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2012
    Posts
    15

    Populate Bound Fields from Unbound Fields in Multiple Items Form

    I am trying to reinvent our inventory database to allow for more efficient data entries.

    I have created a form titled frmInventoryAdd.

    In the form header section, I have unbound fields for NomenclatureIN, PNIN, PriceIN, ReceivedIN, and ConditionIN.

    In the detail section I have fields derived from my Inventory Table for Nomenclature, P/N, S/N, Price, Condition, and Comments.

    My goal here is for the user to type into the unbound fields, and have all of the fields excluding the S/N be automatically filled in from the unbound fields. The S/N (serial numbers) are unique to each device, so that is why the user would enter them in individually. The remaining fields are all common for the entry event.

    I added the follwoing to the after update for the unbound fields:


    __________________________________________________ ______________________________________
    Private Sub ConditionIN_AfterUpdate()
    Me!Condition = Me!ConditionIN
    End Sub

    Private Sub NomenclatureIN_AfterUpdate()
    Me!Nomenclature = Me!NomenIN
    End Sub

    Private Sub PNIN_AfterUpdate()
    Me!PN = Me!PNIN
    End Sub

    Private Sub PRICEIN_AfterUpdate()
    Me!Price = Me!PRICEIN
    End Sub

    Private Sub ReceivedIN_AfterUpdate()
    Me!Received = Me!ReceivedIN
    End Sub
    __________________________________________________ _____________________________________

    This works flawlessly for the first item s/n entry, but not for any additional entries. I enter the unbound data, then add s/n for the first item, but the next line does not autopopulate when I tab through to it.

    Any help would be greatly appriciated!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    Options:

    1. use the Current event with the same code to populate the fields

    2. use code in AfterUpdate event to set DefaultValue property of each control
    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.

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    A step-by-step for June7's second suggestion:

    You can use the AfterUpdate event of the Control holding your data to set the DefaultValue for the Field. From that time forward, until you either manually change the data or close your form, the data will be entered automatically in each New Record.

    Code:
    Private Sub YourControlName_AfterUpdate()
       Me.YourControlName.DefaultValue = """" & Me.YourControlName.Value & """"
    End Sub
    You’ll need to do this for each Control that you want to ‘carry forward.’

    Note that this code/syntax can be used for any Datatype.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    DNASok is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2012
    Posts
    15
    I have input the following into the form "On Current":_________________________________________ __________________________________________________ __________
    Private Sub Form_Current()
    Me!Condition = Me!ConditionIN
    End Sub
    Private Sub Form_Current()
    Me!Nomenclature = Me!NomenIN
    End Sub
    Private Sub Form_Current()
    Me!PN = Me!PNIN
    End Sub
    Private Sub Form_Current()
    Me!Price = Me!PRICEIN
    End Sub
    Private Sub Form_Current()
    Me!Received = Me!ReceivedIN
    End Sub
    __________________________________________________ __________________________________________________ _

    However, when I run Compile, I receive:
    "Compile error:
    Ambiguous name detected: Form_Current"

  5. #5
    DNASok is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2012
    Posts
    15
    Disregard...figured it out...stupid. I know have:
    Private Sub ConditionIN_Current()
    Me!Condition = Me!ConditionIN
    End Sub
    Private Sub NomenclatureIN_Current()
    Me!Nomenclature = Me!NomenIN
    End Sub
    Private Sub PNIN_Current()
    Me!PN = Me!PNIN
    End Sub
    Private Sub PriceIN_Current()
    Me!Price = Me!PRICEIN
    End Sub
    Private Sub ReceivedIN_Current()
    Me!Received = Me!ReceivedIN
    End Sub
    Private Sub ConditionIN_AfterUpdate()
    Me.Condition.DefaultValue = """" & Me.ConditionIN.Value & """"
    End Sub
    Private Sub NomenclatureIN_AfterUpdate()
    Me.Nomenclature.DefaultValue = """" & Me.NomenclatureIN.Value & """"
    End Sub
    Private Sub PNIN_AfterUpdate()
    Me.PN.DefaultValue = """" & Me.PNIN.Value & """"
    End Sub
    Private Sub PriceIN_AfterUpdate()
    Me.Price.DefaultValue = """" & Me.PRICEIN.Value & """"
    End Sub
    Private Sub ReceivedIN_AfterUpdate()
    Me.Received.DefaultValue = """" & Me.ReceivedIN.Value & """"
    End Sub


    Thank you!

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by DNASok View Post
    Disregard...figured it out...
    Sorry, but you haven't!

    All of this is completely invalid:

    Code:
    Private Sub ConditionIN_Current()
     Me!Condition = Me!ConditionIN
    End Sub
    Private Sub NomenclatureIN_Current() 
     Me!Nomenclature = Me!NomenIN
    End Sub
    Private Sub PNIN_Current()
     Me!PN = Me!PNIN
    End Sub
    Private Sub PriceIN_Current()
     Me!Price = Me!PRICEIN
    End Sub
    Private Sub ReceivedIN_Current()
     Me!Received = Me!ReceivedIN
    End Sub


    Only the Form has an OnCurrent event! This event refers to the Record, as a whole! Anything you need to occur, when moving to a Record, needs to be in the Form_Current event, whether it is a single thing or multiple things.

    The rest of your code should be

    Code:
    Private Sub ConditionIN_AfterUpdate()
      Me.ConditionIN.DefaultValue = """" & Me.ConditionIN.Value & """"
    End Sub
    Private Sub NomenclatureIN_AfterUpdate()
      Me.NomenclatureIN.DefaultValue = """" & Me.NomenclatureIN.Value & """"
    End Sub
    Private Sub PNIN_AfterUpdate()
      Me.PNIN.DefaultValue = """" & Me.PNIN.Value & """"
    End Sub
    Private Sub PriceIN_AfterUpdate()
      Me.PriceIN.DefaultValue = """" & Me.PRICEIN.Value & """"
    End Sub
    Private Sub ReceivedIN_AfterUpdate()
      Me.ReceivedIN.DefaultValue = """" & Me.ReceivedIN.Value & """"
    End Sub


    And just so that you understand the difference

    Private Sub ConditionIN_AfterUpdate()
    Me.ConditionIN.DefaultValue = """" & Me.ConditionIN.Value & """"
    End Sub

    The Control name in Red has to match the Control Name in Blue!
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  7. #7
    DNASok is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2012
    Posts
    15
    Quote Originally Posted by Missinglinq View Post
    Sorry, but you haven't!

    All of this is completely invalid:

    Code:
    Private Sub ConditionIN_Current()
     Me!Condition = Me!ConditionIN
    End Sub
    Private Sub NomenclatureIN_Current() 
     Me!Nomenclature = Me!NomenIN
    End Sub
    Private Sub PNIN_Current()
     Me!PN = Me!PNIN
    End Sub
    Private Sub PriceIN_Current()
     Me!Price = Me!PRICEIN
    End Sub
    Private Sub ReceivedIN_Current()
     Me!Received = Me!ReceivedIN
    End Sub


    Only the Form has an OnCurrent event! This event refers to the Record, as a whole! Anything you need to occur, when moving to a Record, needs to be in the Form_Current event, whether it is a single thing or multiple things.

    The rest of your code should be

    Code:
    Private Sub ConditionIN_AfterUpdate()
      Me.ConditionIN.DefaultValue = """" & Me.ConditionIN.Value & """"
    End Sub
    Private Sub NomenclatureIN_AfterUpdate()
      Me.NomenclatureIN.DefaultValue = """" & Me.NomenclatureIN.Value & """"
    End Sub
    Private Sub PNIN_AfterUpdate()
      Me.PNIN.DefaultValue = """" & Me.PNIN.Value & """"
    End Sub
    Private Sub PriceIN_AfterUpdate()
      Me.PriceIN.DefaultValue = """" & Me.PRICEIN.Value & """"
    End Sub
    Private Sub ReceivedIN_AfterUpdate()
      Me.ReceivedIN.DefaultValue = """" & Me.ReceivedIN.Value & """"
    End Sub


    And just so that you understand the difference

    Private Sub ConditionIN_AfterUpdate()
    Me.ConditionIN.DefaultValue = """" & Me.ConditionIN.Value & """"
    End Sub

    The Control name in Red has to match the Control Name in Blue!
    I'm confused because it is working flawlessly with the way I have it. I'll try what you have though!

  8. #8
    DNASok is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2012
    Posts
    15
    Didn't work!

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    DNASok, I am confused. You show code in post #5 for the AfterUpdate event for each control. Why the Current event for each control? Current is a form event, not one associated with controls. At best, VBA will ignore those procedures, seeing them as custom procedures that aren't called from anywhere.
    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.

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

Similar Threads

  1. Replies: 8
    Last Post: 12-05-2011, 01:55 PM
  2. Saving bound and unbound fields
    By mejia.j88 in forum Forms
    Replies: 2
    Last Post: 11-04-2011, 05:09 PM
  3. Replies: 63
    Last Post: 09-16-2011, 04:55 PM
  4. Multiple Items Form - Interaction btw Fields
    By Douglasrac in forum Forms
    Replies: 15
    Last Post: 03-25-2011, 09:31 AM
  5. Replies: 4
    Last Post: 01-20-2011, 10:05 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