Refresh Method Example

The following example illustrates use of the Refresh method to rebuild an rdoResultset on the RemoteData control. The example resets the SQL property with a new query built using the concatenation technique. When the Refresh method is executed, the query is re-executed. Since the Connect property is not changed for each invocation of the Search procedure, the connection is not re-established each time – it is opened only on the first invocation. When the Refresh method is complete, the bound controls reflect data from the columns returned by the query.

Option Explicit
Private Sub Search_Click()
On Error GoTo eh
With MSRDC1
   .Connect = "UID=;PWD=;Database=Pubs;"
   .DataSourceName = "WorkDB"
   .SQL = "Select Au_Fname " _
      & " From Authors " _
      & " Where Au_Lname like '%" _
      & AuthorWanted & "%'"
   Debug.Print .SQL
   .Refresh
    
   If .Resultset.EOF Then
      MsgBox "No authors on file with that last name"
   End If
End With
Exit Sub

eh:
Dim er As rdoError
For Each er In rdoErrors
Debug.Print er
Next
Resume Next
End Sub