Results 1 to 6 of 6
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    RecordSource not refreshing as expected

    A Form that has as its RecordSource the query posted yesterday, (ref: 3/30/21, Query post "Non-updateable query"), where user has requested that pets be added to their resident profile.

    Code:
    SELECT tblRegistry.RegistryID, tblRegistry.LastName, tblRegistry.FirstName, [lastname] & ", " & [firstname] AS Name, tblRegistry.SalID, tblRegistry.Title, tblRegistry.Gender, tblRegistry.RegAs, tblRegistry.Unit, tblRegistry.Parking, tblRegistry.LandLine, tblRegistry.Ext, tblRegistry.Cell, tblRegistry.EMA, tblRegistry.ImageName, tblRegistry.GroupIDs, tblRegistry.Notes, tblRegistry.Selected, tblRegistry.PubCell, tblRegistry.PubEMA, tblRegistry.TxtOkay, tblRegistry.EMOkay, tblRegistry.VoiceOkay, tblRegistry.PrivStaff, tblRegistry.DirPDF, tblPets.AptNum, tblPets.Pet1, tblPets.Sp1, tblPets.Pet2, tblPets.Sp2, tblPrkgStalls.StallNum, tblAutoMfg.MFG, tblAutoModels.Model, tblAutoColors.Color, tblPrkgStalls.LiNum
    FROM ((((tblRegistry LEFT JOIN tblPets ON tblRegistry.Unit = tblPets.AptNum) LEFT JOIN tblPrkgStalls ON tblRegistry.Parking = tblPrkgStalls.StallID) LEFT JOIN tblAutoMfg ON tblPrkgStalls.MfgID = tblAutoMfg.MfgID) LEFT JOIN tblAutoModels ON tblPrkgStalls.ModID = tblAutoModels.ModelID) LEFT JOIN tblAutoColors ON tblPrkgStalls.ColorID = tblAutoColors.ColorID;
    User clicks the option to add pets, the following event code runs:
    Code:
    Private Sub lblAddPets_Click()
    If Nz(DLookup("AptNum", "QPets", "AptNum = " & Me.tbUnit)) = 0 Then
        InitPets (Me.tbUnit)
        Me.Requery
    End If
    
    Me.lblAddPets.Caption = "Pet(s)"
    
    Me.tbsp1.Visible = True
    Me.tbPet1.Visible = True
    Me.tbSp2.Visible = True
    Me.tbPet2.Visible = True
    
    End Sub
    Public Function InitPets(AptNo)
    Dim I As Integer
    Dim rsPets As DAO.Recordset
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    '
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    
    Set rsPets = DBEngine(0)(0).OpenRecordset("QPets")
    
    With rsPets
        .AddNew
        !AptNum = AptNo
        !Sp1 = "Dog:"
        !Sp2 = "D/C:"
        .Update
    End With
    If Me.Dirty Then Me.Dirty = False
    
    rsPets.Close
    Set rsPets = Nothing
    End Function
    The new record in the pets table is in fact created correctly, but when the user attempts to toggle the species field they are greeted with the following error:


    Click image for larger version. 

Name:	003.jpg 
Views:	11 
Size:	174.3 KB 
ID:	44875
    If I exit the form and re-open, the problem goes away. I obviously need something else, but I can't figure out what?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,523
    you should just run an append query , rather than writing all this code.

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Would you care to elaborate? I assume you mean append a new record to the pets table, and if so, how would that effect the issue here? The Requery of the form's RecordSource should have caused the bound fields to populate per the pets table update.

  4. #4
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    I got rid of the error by requery of the bound controls. However, I loose "my place" in the form's RecordSource after a add a record to the pets table. The form opens having been passed the current record, but again, I loose that positioning and need to get back.
    Code:
    Private Sub Form_Open(Cancel As Integer)
    '*=*=*=*=*=*=*=*=*=*=*=*=( OPEN OPEN OPEN OPEN OPEN )=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    '
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    lngRecID = Me.OpenArgs
    
    Me.RecordsetClone.FindFirst "RegistryID = " & lngRecID             
    Me.Bookmark = Me.RecordsetClone.Bookmark
    
    End Sub

  5. #5
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,784
    Actually, you're "losing" your place. See if this one helps.
    https://www.accessforums.net/showthread.php?t=83334
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Got it,
    Thanks,
    Bill

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

Similar Threads

  1. Refreshing Data
    By Pure Salt in forum Access
    Replies: 2
    Last Post: 05-12-2014, 11:52 AM
  2. Refreshing a listbox
    By PatrickCairns in forum Programming
    Replies: 9
    Last Post: 12-07-2012, 05:26 PM
  3. SubForm not refreshing
    By hawkins in forum Access
    Replies: 2
    Last Post: 08-16-2011, 04:30 PM
  4. Refreshing a subform?
    By Shag84 in forum Forms
    Replies: 4
    Last Post: 08-07-2011, 10:07 AM
  5. RecordSource help
    By mann2x in forum Access
    Replies: 3
    Last Post: 10-05-2010, 06:44 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