1
votes

I have a popup form with a combobox that lets you select a value from the primary key of one of my tables.

After I select a value, I want the popup form to close and for another form to open with the observation I selected in the first form populating the second form.

This code does everything I want except close the first popup form:

Private sub ID_AfterUpdate()
Dim id as String
id=Me.ComboBox
DoCmd.OpenForm "Part II",,,,,,id
end sub

This code does what I want except it doesn't close the popup form so I tried:

Private sub ID_AfterUpdate()
Dim id as String
id=Me.ComboBox
DoCmd.Close
DoCmd.OpenForm "Part II",,,,,,id
end sub

But now it doesn't work at all. I simply get "Object doesn't support this property or method". I also tried:

Private sub ID_AfterUpdate()
Dim id as String
id=Me.ComboBox
DoCmd.OpenForm "Part II",,,,,,id
DoCmd.Close    
end sub

But that doesn't work at all, doesn't open the second form or close the first form.

1
Replace DoCmd.Close with Me.Visible = False instead. - RBarryYoung

1 Answers

1
votes

After OpenForm, do DoCmd.Close acForm, Me.Name to close the current form --- the form whose code module contains your ID_AfterUpdate procedure.

Private Sub ID_AfterUpdate()
    Dim id As String
    id = Me.ComboBox
    DoCmd.OpenForm "Part II", , , , , , id
    DoCmd.Close acForm, Me.Name
End Sub