Solved Dropdown not requerying (1 Viewer)

Kayleigh

Member
Local time
Today, 06:37
Joined
Sep 24, 2020
Messages
706
I have two simple data entry forms. The first (DEfrmCovidTest) has a drop-down to all entries currently in table with option to go to second data entry form (DEfrmCovidConsent) to add new entries. This should requery onClose event so the dropdown now includes new entry but it is not working. This is my code for the onClose event:

Code:
Private Sub cmdClose_Click()

Dim intPressed As Variant

 If (Me.Dirty = True) And (Me.NewRecord = False) Then
   intPressed = MsgBox("Do you want to save changes?", vbYesNo + vbQuestion, gstrAppTitle)
        If intPressed = 7 Then
        Me.Undo
        
        DoCmd.Close acForm, Me.Name
        Forms!frmCovidRegister.Requery
        Forms!frmDEfrmCovidTest.Requery
        On Error Resume Next
        Forms!frmDEfrmCovidTest.Visible = True
        
        Exit Sub
         Else
      DoCmd.Save acForm, Me.Name
      DoCmd.Close acForm, Me.Name
      Forms!frmCovidRegister.Requery
      Forms!frmDEfrmCovidTest.Requery
      On Error Resume Next
      Forms!frmDEfrmCovidTest.Visible = True
      
        Exit Sub
        End If
      Else
      DoCmd.Save acForm, Me.Name
      DoCmd.Close acForm, Me.Name
      On Error Resume Next
      Forms!frmCovidRegister.Requery
      Forms!frmDEfrmCovidTest.Requery
      
      Forms!frmDEfrmCovidTest.Visible = True
    End If

End Sub
What can I change?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 14:37
Joined
May 7, 2009
Messages
19,169
the command:

DoCmd.Save acForm, Me.Name

will not Save your Record. it will Save the Form.

you must issue:

Me.Dirty = False, to save the record.
 

Kayleigh

Member
Local time
Today, 06:37
Joined
Sep 24, 2020
Messages
706
I see. So changed that and now it will display in dropdown but only after closing and re-opening first form...
 

missinglinq

AWF VIP
Local time
Today, 02:37
Joined
Jun 20, 2003
Messages
6,423
Doing a Requery of a Form doesn't Requery its Comboxes or Listboxes...they must be explicitly Requeried!

Linq ;0)>
 

Kayleigh

Member
Local time
Today, 06:37
Joined
Sep 24, 2020
Messages
706
Thanks for pointing me in right direction!

For others with this issue...found some useful code here.
 

Users who are viewing this thread

Top Bottom