在使用dataenvironment作为datareport的数据源,使用command作为datamember,如何动态改变command,而不是事前绑定?能否提供代码?谢谢!
我在按钮事件中动态改变command1,但不能绑定数据?
Private Sub Command1_Click()
sql = "select * from 学生1"
DataEnvironment1.Commands("command1").CommandType = adCmdTable
DataEnvironment1.Commands("command1").CommandText = "sql"
Set DataReport1.DataSource = DataEnvironment1
DataReport1.DataMember = "command1"
MsgBox DataReport1.Sections("Section1").Controls(1).Name
DataReport1.Sections("Section1").Controls(1).DataMember = "command1"
DataReport1.Sections("Section1").Controls(1).DataField = "字段1"
DataReport1.Show
End Sub