Results 1 to 10 of 10
  1. #1
    jlindquist23 is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Jan 2019
    Posts
    43

    Auto Fill Fields in a Form using a Combo field

    I'm using the ItemNo Combo box to update 28 other fields.
    The first 4 work fine. The other 24 don't update. My column count is set to 28. Any other thoughts why the others won't fill in?
    I've attached a picture.
    Here's my OnChange formula for that field. No errors happen when I run it.

    Private Sub cboItemNo_Change()Me.txtRC_LCL.Value = Me.cboItemNo.Column(1)
    Me.txtRC_UCL.Value = Me.cboItemNo.Column(2)
    Me.txtSagePotTemp.Value = Me.cboItemNo.Column(3)
    Me.txtSageQTemp.Value = Me.cboItemNo.Column(4)
    Me.txtSageRackQty.Value = Me.cboItemNo.Column(5)


    Me.txtSageLoadTime.Value = Me.cboItemNo.Column(6)
    Me.txtSageHardnessAim.Value = Me.cboItemNo.Column(7)
    Me.txtSageBTPinDia.Value = Me.cboItemNo.Column(8)
    Me.txtSageBTVBlock.Value = Me.cboItemNo.Column(9)
    Me.txtSageBTQty.Value = Me.cboItemNo.Column(10)
    Me.txtSageBTLot.Value = Me.cboItemNo.Column(11)
    Me.txtSageBTMin.Value = Me.cboItemNo.Column(12)
    Me.txtSageSurHdnsQty.Value = Me.cboItemNo.Column(13)
    Me.txtSageSurHdnsLot.Value = Me.cboItemNo.Column(14)
    Me.txtSageSurHdnsMin.Value = Me.cboItemNo.Column(15)
    Me.txtSageGrindHdnsQty.Value = Me.cboItemNo.Column(16)
    Me.txtSageGrindHdnsLot.Value = Me.cboItemNo.Column(17)
    Me.txtSageGrindHdnsMin.Value = Me.cboItemNo.Column(18)
    Me.txtSageEndSurHdnsQty.Value = Me.cboItemNo.Column(19)
    Me.txtSageEndSurHdnsLot.Value = Me.cboItemNo.Column(20)
    Me.txtSageEndSurHdnsMin.Value = Me.cboItemNo.Column(21)
    Me.txtSageHyperlink.Value = Me.cboItemNo.Column(22)
    Me.txtSageStrikeTestQty.Value = Me.cboItemNo.Column(23)
    Me.txtSageStrikeTestLot.Value = Me.cboItemNo.Column(24)
    Me.txtSageMicro.Value = Me.cboItemNo.Column(25)
    Me.txtSageMemo.Value = Me.cboItemNo.Column(26)
    Me.txtSageD4ProgramNumber.Value = Me.cboItemNo.Column(27)
    Me.txtSageD4PartsPerRack.Value = Me.cboItemNo.Column(28)
    End Sub

    Thanks for you help!!!
    Jen
    Attached Thumbnails Attached Thumbnails Capture.JPG  

  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,529
    Potentially stupid question, but are all the fields in the row source of the combo?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    jlindquist23 is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Jan 2019
    Posts
    43
    Yes. I made sure, but appreciate the thought.

  4. #4
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,421
    Just a shot in the dark, but try
    Code:
    Me.txtSageRackQty.Value = NZ(Me.cboItemNo.Column(5),0)
    to see if null values are the problem.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,953
    I have to wonder why all this data is duplicated and not just saving the ID?
    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.

  6. #6
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,421
    I have to wonder why all this data is duplicated and not just saving the ID?
    Or just have the rowsource for the combobox be the recordsource for the form.

  7. #7
    jlindquist23 is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Jan 2019
    Posts
    43

    NZ added to formula

    Quote Originally Posted by davegri View Post
    Just a shot in the dark, but try
    Code:
    Me.txtSageRackQty.Value = NZ(Me.cboItemNo.Column(5),0)
    to see if null values are the problem.
    Hmmm... interesting. That put zeros in all the boxes.
    Sooo... that means that it thinks my data is empty?

    But the data is there... see attachments.Click image for larger version. 

Name:	Capture.JPG 
Views:	12 
Size:	49.9 KB 
ID:	37831Click image for larger version. 

Name:	Capture1.JPG 
Views:	13 
Size:	23.0 KB 
ID:	37832

  8. #8
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,421
    Sooo... that means that it thinks my data is empty?
    Indeed it does.

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,529
    Can you attach the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,815
    Also wonder why data that already exists is being duplicated. Sounds like underlying table design issue.
    Regardless, will say that if you knew you'd be doing this from the outset, then you could have added the column number to the control name and shorten the code to something kind of like
    Code:
    Private Sub cboItemNo_Change()
    Dim ctl As Control
    Dim int As Integer
    
    For Each ctl in Me.Controls
      If ctl.ControlType = acTextbox Then
        int = Right(ctl.Name,1)
        .ctl = Nz(.cboItemNo.Column(int),"")
      End If
    Next
    
    End Sub
    If the first control name encountered ended in 4, the Right function would set int = 4. Then the value gets set to what's in column 4. If there's no value in it, then control is set to empty string. You could use any allowable alternate value for Nz. If you had a bunch of other textboxes, they wouldn't get a number at the end of their name.
    Note: I would never start a name with a number. I also see that the absence of a number or numbers greater than 9 would have to be dealt with, but seeing as how this won't get used anyway, will leave it as is. Just thought it might be food for future thought. Upon further reflection, using the control tag would be even simpler.
    Last edited by Micron; 03-14-2019 at 10:08 PM. Reason: code correction & added info
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 3
    Last Post: 02-17-2019, 08:54 PM
  2. auto fill fields based on another field
    By dbell in forum Forms
    Replies: 18
    Last Post: 05-26-2014, 01:46 PM
  3. Replies: 3
    Last Post: 03-21-2012, 01:43 PM
  4. Auto-Fill text fields in the form
    By sk88 in forum Access
    Replies: 2
    Last Post: 01-10-2012, 08:22 PM
  5. Replies: 3
    Last Post: 10-13-2011, 04:42 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