Set rac=createobject("adodb.recordset")
sub_his="select csh.num_history_id, csh.num_client_id,csh.num_service_id, csh.vc2_service_conf_code, csh.dat_subscribe_time, csh.dat_marketing_time from CRM_SUBSCRIBE_HISTORIES csh where csh.num_client_id in('"&sht.cells(2,11)&")"
rac.Open sub_his,Cnn
print rac.Fields.Count
print sub_his
If not rac.EOF Then
rac.MoveFirst
For i=1 to rac.Fields.Count-1
P4="历史ID--"& rac.Fields.Item("num_history_id").Value &";客户ID--"&rac.Fields.Item("num_client_id").Value &";业务--- "&rac.Fields.Item("vc2_service_conf_code").Value &";订购时间"&rac.Fields.Item("dat_subscribe_time").Value &";创建时间"&rac.Fields.Item("dat_marketing_time").Value
sht.cells(11,i+1)=P4
bak5=bak5 &"'"& rac.Fields.Item("num_history_id").Value &"',"
rac.MoveNext
Next
sht.cells(2,14)=mid(bak5,1,len(bak5)-1)
print bak5
else
sht.cells(11,2)=""
sht.cells(11,2)="订购历史表无信息"
End If
rac.Close
Set rac=nothing