Hi,
I'm trying to create a new instance of a form, add a property (class object) to it and make it visible.
The best I've done is the code below. But this only shows the form for as long as the code runs. In other words, the form becomes visible and disappears again immediately.
I don't see any form.Show() method. I don't think DoCmd.OpenForm() is an option unless something like this
But that doesn't work of course. Any other ideas?
I'm trying to create a new instance of a form, add a property (class object) to it and make it visible.
The best I've done is the code below. But this only shows the form for as long as the code runs. In other words, the form becomes visible and disappears again immediately.
Code:
Private Sub btnEditCountry_Click()
Dim c As clsCountry
On Error GoTo ErrorHandler
' Instantiate country object
Set c = New clsCountry
' Set country properties
c.CountryID = 5
c.CountryName = "Belgium"
c.ShortCode = "BE"
' Open edit form
With New Form_frmEditCountry
.Country = c
.Visible = True
End With
Exit Sub
ErrorHandler:
MsgBox "Something went wrong: " + Err.Description
End Sub
I don't see any form.Show() method. I don't think DoCmd.OpenForm() is an option unless something like this
Code:
Dim f As Form
Set f = New Form
DoCmd.OpenForm f
But that doesn't work of course. Any other ideas?