|
Private Sub Cmb创建_Click()
Dim str, XM As String
Dim RS7 As Recordset
Dim DB7 As Database
Set DB7 = OpenDatabase(ThisWorkbook.Path & "\" & "资料库.MDB")
Set RS7 = DB7.OpenRecordset(Name:="员工资料", Type:=dbOpenDynaset)
With RS7
For n = 1 To 4
.FindFirst "ID=" & n
If Not .NoMatch Then
XM = .Fields("姓名").Value
If n = 1 Then
str = XM
Else
str = str & "," & XM
End If
End If
Next
End With
RS7.Close
Set RS7 = Nothing
Set DB7 = Nothing
crr = Array(str) ????请问这里我的str 要怎么写,感谢各位老师
For i = 0 To 3
Set mycmd(i).com = Controls.Add("Forms.CommandButton.1", crr(i), True) 下标越界
With mycmd(i).com
.Left = (i + 1) * 50
.Top = 20
.Width = 40
.Height = 30
.Caption = crr(i)
End With
Next
End Sub
类
Public WithEvents com As MSForms.CommandButton
Public Sub com_Click()
myname = com.Caption '此处获得按钮名称
MsgBox "已生成控件" & myname
'可以根据不同myname,继续你的代码
End Sub
|
|