Results 1 to 3 of 3

Thread: [RESOLVED] What event is fired when a modal form returns to the calling form

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2006
    Posts
    365

    Resolved [RESOLVED] What event is fired when a modal form returns to the calling form

    Hello all,

    I have a form being opened modal by a calling form
    Code:
    Private Sub cmdWorkForm_Click()
        If txtSCID.Text = "" Then
            frmSubContractor.Refresh
        End If
        lngWrkid = CLng(txtSCID.Text)
        frmSubWork.Show vbModal, frmSubContractor
    End Sub
    Once the frmSubWork form is closed I would like to know what event is fired by VB? The reason is I have an ADODC that feeds a read only datagrid showing all of the work a subcontractor has carried out.

    The issue I am having is the datagrid, once the form is returned focus is not showing all of the records.
    Code:
    Private Sub UpdateDatagrid()
        Dim strSQL As String
        Dim lngSCID As Long
        Dim dgRS As ADODB.Recordset
        Set dgRS = New ADODB.Recordset
        strSQL = "SELECT * FROM tblSCPay WHERE SubContractor = " & txtSCID.Text
        With dgRS
            .ActiveConnection = cn
            .CursorType = adOpenForwardOnly
            .CursorLocation = adUseClient
            .LockType = adLockReadOnly
            .Source = strSQL
            .Open , , , , adCmdText
        End With
        Set dgdSCWork.DataSource = dgRS
        
        With dgdSCWork
            .Refresh
        End With
        
        dgRS.Close
        Set dgRS = Nothing
    End Sub
    followed by
    Code:
    Private Sub Form_GotFocus()
        Call UpdateDatagrid
    End Sub
    that achieves nothing, hence I need to know what event is firing.

    Any assistance is very much appreciated.

    Kind regards

    Steve

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: What event is fired when a modal form returns to the calling form

    There is no event for it, and no need for one - because the very next line of code will run.

    Just add your code immediately after showing the form:
    Code:
    ...
        frmSubWork.Show vbModal, frmSubContractor
        Call UpdateDatagrid
    End Sub

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2006
    Posts
    365

    Re: What event is fired when a modal form returns to the calling form

    Hello Si,

    Perfect. Thanks very much.

    Steve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width