|
Private Sub Command13_Click()
Dim Qdf As DAO.QueryDef
Dim rs As New ADODB.Recordset
Dim strSQL As String, strCriteria As String
Dim ctl As Control
If IsNull(Me.Text14) Then
MsgBox "Enter the Path frist"
Me.Text14.SetFocus
Exit Sub
End If
Set Qdf = CurrentDb.QueryDefs("Q")
For Each ctl In Me.Controls
If TypeOf ctl Is OptionButton Then
If ctl Then
strCriteria = strCriteria & "'" & ctl.Name & "',"
End If
End If
Next
If strCriteria = "" Then
strSQL = "select * from 表1 order by 籍贯"
Else
strSQL = "select * from 表1 where 籍贯 in (" & strCriteria & ") order by 籍贯"
End If
Qdf.SQL = strSQL
strSQL = "select distinct 籍贯 from Q"
With rs
.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
Do While Not .EOF
Set Qdf = CurrentDb.QueryDefs("Out")
strSQL = "select * from 表1 where 籍贯='" & .Fields(0) & "'"
Qdf.SQL = strSQL
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Out", Me.Text14, , .Fields(0)
.MoveNext
Loop
.Close
End With
Set rs = Nothing
Set Qdf = Nothing
End Sub
[ 本帖最后由 Henry D. Sy 于 2008-12-23 20:31 编辑 ] |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|