Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2005
    Location
    Texas
    Posts
    100

    Unanswered: Can't change the record source of an ADO data control, help!!!

    I'm trying to change the RecordSource property of an ADO data control (ADODC) in VB.

    I've written a function that passes in a string and tries to assign the value of the RecordSource property to that string, as so:

    Code:
    Public Sub ChangeDataSource(strsql As String)
    
        DataGrid.dcDataSheetSource.RecordSource = strsql
    
    End Sub
    (where DataGrid is the form name and dcDataSheetSource is the name of the ADO data control)

    Here's how I'm calling it in testing in the click event of a test button:

    Code:
    Private Sub cmdTest1_Click()
    
    Dim strsql As String
    
    strsql = "EXEC sp_FESpecialPipelineReport @Filter=''"
    
    
    Call ChangeDataSource(strsql)
    
    End Sub
    There are no errors or anything; it just plain never updates the record source. What am I doing wrong? Thanks!

  2. #2
    Join Date
    Dec 2005
    Location
    Texas
    Posts
    100

    Nevermind....

    This seems to work, though I don't know why.

    Code:
    Public Sub ChangeDataSource(strSQL As String)
    
        With DataGrid
            .dcDataSheetSource.CommandType = adCmdText
            .dcDataSheetSource.RecordSource = strSQL
            .dcDataSheetSource.Refresh
        End With
        
    End Sub

Posting Permissions

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