Routines between different forms in VB

0

Well, I'm doing an application in VBA with 2 forms. In form1 I have a flexgrid that loads records from a database and in form 2 I have a textbox that inserts registration in the same database. What I want to do is to click the add button of form2 to grid of form1 update automatically. How do I upgrade because they are different forms?

ps: I can not have buttons on form1 to update, it has to be even automatically after clicking the add button on form2.

Thank you:)

    
asked by anonymous 17.03.2017 / 00:54

1 answer

0

What you need would be something like:

//Form1
Public Sub Atualizar()
    MsgBox "Atualizado"
End Sub

Private Sub Command1_Click()

    Dim objForm2 As Form2

    Set objForm2 = New Form2

    Set objForm2.Formulario = Me

    objForm2.Show 1

    Set objForm2 = Nothing

End Sub

//Form2
Private m_objFormulario As Form1

Public Property Set Formulario(ByVal oValue As Form1)
    Set m_objFormulario = oValue
End Property

Private Sub Command1_Click()
    Call m_objFormulario.Atualizar
    Unload Me
End Sub
    
17.03.2017 / 22:14