Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba 在Access窗体上动态设置组合框的值_Vba_Ms Access - Fatal编程技术网

Vba 在Access窗体上动态设置组合框的值

Vba 在Access窗体上动态设置组合框的值,vba,ms-access,Vba,Ms Access,我试图根据对另一个组合框的选择动态设置一个组合框的值。每次运行时,都会显示对象变量或未设置块变量 Option Compare Database Private Sub cmbReport_AfterUpdate() 'Gets the Report If cmbReport = "Audit type" Then Set Data = CurrentDb.CreateQueryDef("", "SELECT AuditTypeName FROM tblAud

我试图根据对另一个组合框的选择动态设置一个组合框的值。每次运行时,都会显示对象变量或未设置块变量

Option Compare Database

Private Sub cmbReport_AfterUpdate()
    'Gets the Report
    If cmbReport = "Audit type" Then
        Set Data = CurrentDb.CreateQueryDef("", "SELECT AuditTypeName  FROM tblAuditType")
    End If

    Set rs = Data.OpenRecordset

    'Sets the data
    With Me.cmbData
        .Recordset = rs
    End With
End Sub

如果cmdData是一个组合框,则它应该是
.Rowsource
而不是
.Recordset

Private Sub cmbReport_AfterUpdate()
    If cmbReport = "Audit type" Then
        cmbData.Rowsource = "SELECT AuditTypeName FROM tblAuditType"
    End If
End Sub

如果cmdData是一个组合框,则它应该是
.Rowsource
而不是
.Recordset

Private Sub cmbReport_AfterUpdate()
    If cmbReport = "Audit type" Then
        cmbData.Rowsource = "SELECT AuditTypeName FROM tblAuditType"
    End If
End Sub

如果cmdData是一个组合框,则它应该是
.Rowsource
而不是
.Recordset

Private Sub cmbReport_AfterUpdate()
    If cmbReport = "Audit type" Then
        cmbData.Rowsource = "SELECT AuditTypeName FROM tblAuditType"
    End If
End Sub

如果cmdData是一个组合框,则它应该是
.Rowsource
而不是
.Recordset

Private Sub cmbReport_AfterUpdate()
    If cmbReport = "Audit type" Then
        cmbData.Rowsource = "SELECT AuditTypeName FROM tblAuditType"
    End If
End Sub

确切地说,不需要创建QueryDef。确切地说,不需要创建QueryDef。确切地说,不需要创建QueryDef。确切地说,不需要创建QueryDef。