Results 1 to 12 of 12
  1. #1
    breakingme10 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Oklahoma
    Posts
    153

    Talking Auto Populate Skips Displaying Some Fields in the Form

    I use a combo box with a row source of
    SELECT Sites.Well_ID, Sites.Sec, Sites.Track, Sites.Region, Sites.County FROM Sites;


    Bound to column 1 which is the PK. And is the Name of the Well Site Example= "Bert 1H-26" is one of my Well_IDs.
    I use an after update event to auto populate the fields of section, track, region, county and origin.
    I'm not going to go into explaining why i need the data to essentially be redundant and stored in two tables i just do.
    so my code for the after update is:
    Code:
    Private Sub Lease_AfterUpdate()
    Dim varSec, varTrack, varRegion, varCounty, varOrigin As Variant
        varSec = DLookup("Sec", "Sites", "Lease = [Well_ID]")
        varTrack = DLookup("Track", "Sites", "Lease = [Well_ID]")
        varRegion = DLookup("Region", "Sites", "Lease = [Well_ID]")
        varCounty = DLookup("County", "Sites", "Lease = [Well_ID]")
        varOrigin = DLookup("Well_ID", "Sites", "Lease = [Well_ID]")
        If (Not IsNull(varSec)) Then Me![Sec] = varSec
        If (Not IsNull(varTrack)) Then Me![Track] = varTrack
        If (Not IsNull(varRegion)) Then Me![Region] = varRegion
        If (Not IsNull(varCounty)) Then Me![County] = varCounty
        If (Not IsNull(varOrigin)) Then Me![Origin] = varOrigin
    End Sub
    Yes the Origin and the Well_ID are almost always the same! Every once in awhile there is an exception where the driver will write the actual location (ex. Featherston, OK) instead of the lease name on origin but mostly its the same.
    The form i use is a "digital" version of our paper carbon copy water ticket forms that the drivers fill out in the field, and in my reports I use it to print the reproduced water ticket for when the ticket is damaged somehow and like the ones i'm looking at right now are covered in coffee stains (at least i hope its coffee stains).
    My problem is that the "Track" and "Region" don't fill in on the form until i click inside the text box, then it fills it in. What am i doing wrong?

  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,640
    Try changing bang to dot:

    Me.Track = varTrack

    I'd use a recordset so I only made one trip to the data rather than 5.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    breakingme10 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Oklahoma
    Posts
    153
    I'm not sure how to use a recordset, i'm still new at access

  4. #4
    breakingme10 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Oklahoma
    Posts
    153
    Changing it to the Me.Track made no difference.

  5. #5
    breakingme10 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Oklahoma
    Posts
    153
    Does anyone know why it only populates the field once i click inside the text box?

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    I've seen it with the bang vs dot, but you say that didn't help. I've seen it happen on a db I created but it was with a 2007 db being run on the 2010 runtime. For some reason, going back to the 2007 runtime fixed several users, though not all were experiencing the problem. Many still ran the 2010 runtime and didn't experience the problem. It was a puzzler.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    breakingme10 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Oklahoma
    Posts
    153
    I ended up having worse issues than a few txt fields not showing the correct data until i clicked inside them, so i lost track of this post.
    But with other issues resolved. I'm back to being absolutely stumped! I've tried turning autotab on and off for the fields but no difference. I've even added a field to it, and no difference! I use the same code on a copy of the form for a different table to store strictly the newfield tickets and i have the same issue on that form also.
    Image1= After selecting the lease in the combo box
    Image2=Clicking inside the "LeaseT" field to make it display the value
    Image3=Clicking inside the "LeaseR" field to make it display the value
    Image4=Highlighted all the fields that are auto populated by the lease combo box.

    Click image for larger version. 

Name:	enteredintocombobox.PNG 
Views:	7 
Size:	29.0 KB 
ID:	16724Click image for larger version. 

Name:	clickinsideTfield.PNG 
Views:	7 
Size:	34.5 KB 
ID:	16725Click image for larger version. 

Name:	clickinsideRfield.PNG 
Views:	7 
Size:	34.5 KB 
ID:	16726Click image for larger version. 

Name:	highlightfieldsupdatedbyvba.PNG 
Views:	7 
Size:	35.3 KB 
ID:	16727



    Code:
    Private Sub LeaseCombo_AfterUpdate()Dim varSec, varTrack, varRegion, varCounty, varOrigin, varRC As Variant
        varSec = DLookup("SEC", "NewfieldCoalgateSites", "Lease = [WELL_ID]")
        varTrack = DLookup("TRACK", "NewfieldCoalgateSites", "Lease = [WELL_ID]")
        varRegion = DLookup("REGION", "NewfieldCoalgateSites", "Lease = [WELL_ID]")
        varCounty = DLookup("COUNTY", "NewfieldCoalgateSites", "Lease = [WELL_ID]")
        varOrigin = DLookup("WELL_ID", "NewfieldCoalgateSites", "Lease = [WELL_ID]")
        varRC = DLookup("RC_Number", "NewfieldCoalgateSites", "Lease = [WELL_ID]")
        If (Not IsNull(varSec)) Then Me.Sec = varSec
        If (Not IsNull(varTrack)) Then Me.Track = varTrack
        If (Not IsNull(varRegion)) Then Me.Region = varRegion
        If (Not IsNull(varCounty)) Then Me.County = varCounty
        If (Not IsNull(varOrigin)) Then Me.Origin = varOrigin
        If (Not IsNull(varRC)) Then Me.RC_NUMBER = varRC
    End Sub



    Does anyone have a clue why this is happening?

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    It's a shot in the dark, but try adding

    Me.Repaint

    at the end.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    breakingme10 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Oklahoma
    Posts
    153
    Ok I added me.Requery at the end because i read in another thread that that would work with combo boxes and i figured eh same concept for text boxes and of course it works better than ever! previously if i changed the combo box value it would not change the sec t r values to match but now it does! I came back here to share my findings and i see someone else came to the same conclusion!
    It's a shot in the dark, but try adding

    Me.Repaint


    at the end.

  10. #10
    breakingme10 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Oklahoma
    Posts
    153
    well i spoke too soon, it works for one form, the one that is for newfield tickets
    but not the other form, the other form it just automatically goes to the first record afterupdate of the leasecombo! i'm not sure why.

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Did you try Repaint? Requery will go to the first record:

    http://www.baldyweb.com/Requery.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  12. #12
    breakingme10 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Oklahoma
    Posts
    153
    I tried repaint it didn't work either. why would requery work on the newfield one and not this one? they are essentially the same table i just separate the newfield from the other companies. its not making much sense.

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

Similar Threads

  1. How do I auto populate several fields at once
    By learmanj in forum Programming
    Replies: 4
    Last Post: 07-20-2013, 11:41 AM
  2. Replies: 1
    Last Post: 06-20-2013, 10:35 AM
  3. Auto Populate two fields
    By funkygoorilla in forum Access
    Replies: 7
    Last Post: 08-31-2011, 09:06 PM
  4. Replies: 3
    Last Post: 10-05-2009, 07:22 AM
  5. Auto populate fields on a form
    By ldarley in forum Forms
    Replies: 0
    Last Post: 08-14-2008, 09:39 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