vbams-accessadp

ADP Alter view in sql from access coding


I have unique issue regarding ADP. I successfully linked SQL database to Access, but here are the issues. I want to update current view, I mean alter view with desired settings....

Is there any way, One can Alter SQL View Design from Access-VBA programming?


Solution

  • Here are the some basic structure you can follow, in matter of ADP.

    Create recordset using SQL database and assign it to form

    Dim rsTest As ADODB.Recordset
    Set rsTest = New ADODB.Recordset
    sql1 = "SELECT * FROM Test"
    rsTest.Open sql1, CurrentProject.Connection, adOpenForwardOnly, adLockOptimistic, adCmdText
    

    And then you can assign that recordset to form.

    But in case, when you want to perform any operation direct to SQL Server,

    sql1 = "Update Test Set TF=1"
    DoCmd.RunSQL sql1
    

    In your case you can simply write SQL Command for alter view and simply say DoCmd.RunSQL sql1.

    Hope that will help you.