Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Private Sub Command1_Click()
DataReport1.Show
End Sub
Private Sub Command2_Click()
rs.Close
cn.Close
Unload Me
End Sub
Private Sub Form_Load()
Dim connstr As String
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & App.Path & " \ball.mdb"
cn.Open connstr
sql = "Select * from man where man"
rs.CursorLocation = adUseClient
If Option1.Value Then
sql = "SELECT man.fno, man.name, man.tel, man.bbb, man.addr " & _
"From man WHERE (((man.sty)=2))" '列印貴賓
ElseIf Option2.Value Then
sql = "SELECT man.fno, man.name, man.tel, man.bbb, man.addr " & _
"From man WHERE (((man.sty)=1))" '列印會員
Else
sql = "SELECT man.fno, man.name, man.tel, man.bbb, man.addr " & _
"From man WHERE (((man.sty) Between 1 And 2))"
End If
rs.Open sql, cn
Set DataReport1.DataSource = rs
With DataReport1.Sections("section1")
.Controls("text1").DataField = "fno"
.Controls("text2").DataField = "name"
.Controls("text3").DataField = "tel"
.Controls("text4").DataField = "bbb"
.Controls("text5").DataField = "addr"
End With
rs.Close
Set rs = Nothing
End Sub