Private Sub Combo0_GotFocus()
With Combo0
For j = .ListCount - 1 To 0 Step -1
.RemoveItem j
Next
.AddItem "A"
.AddItem "B"
.AddItem "C"
End With
End Sub
Private Sub Command2_Click()
CurrentDb.QueryDefs("Q1").SQL = "select * from " & Me.Combo0.Value
Me.SUBQ1.Form.RecordSource = "select * from " & Me.Combo0.Value
Me.Requery
End Sub
为了避免combo0为空导致出错,严谨一点,还要加上:If Nz(Combo0, 0) <> 0 Then,如下:
Private Sub Command2_Click()
If Nz(Combo0, 0) <> 0 Then
CurrentDb.QueryDefs("Q1").SQL = "select * from " & Me.Combo0.Value
Me.SUBQ1.Form.RecordSource = "select * from " & Me.Combo0.Value
Me.Requery
end if
End Sub