Solved Dropdown not requerying (1 Viewer)

Krayna

Member
Local time
Today, 02:02
Joined
Sep 24, 2020
Messages
300
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

error reading drive A:
Local time
Today, 09:02
Joined
May 7, 2009
Messages
12,011
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.
 

Krayna

Member
Local time
Today, 02:02
Joined
Sep 24, 2020
Messages
300
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
Yesterday, 21:02
Joined
Jun 20, 2003
Messages
6,411
Doing a Requery of a Form doesn't Requery its Comboxes or Listboxes...they must be explicitly Requeried!

Linq ;0)>
 

Krayna

Member
Local time
Today, 02:02
Joined
Sep 24, 2020
Messages
300
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