开发者

Access VBA: Setting RecordSource of form as a RecordSet

I have two form. One开发者_StackOverflow社区 will display records form a RecordSet that the other form will point to.

    Private Sub Form_Load()

        Dim rs As ADODB.Recordset
        Set rs = CurrentDb.OpenRecordset(Forms("reportSelection").Controls("reportComboBox").value)
        RecordSource = rs

    End Sub

So, when the display form loads, it will grab the value from a combobox populated with recordset names in the other form, and open it as a recordset.

But I'm getting a type mismatch at RecordSource = rs, I dont understand why, how is RecordSource a different type than RecordSet?

Any help is appreciated! Thanks!


You need to supply a SQL query as a String to the RecordSource Property.

Private Sub Form_Load()
    Me.RecourdSource = "SELECT Hello FROM World" 
End Sub

Some docs you might find helpful.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜