I have tried using Office controls in VB by adding the Microsoft Forms 2.0 object library. I presume you have done this also.
It worked for me, but I really wish now I had not tried doing it. The problems I had outweighed any benefits and made the app hard to maintain.
The main problem that I ran into was that Vb seems to not be able to identify the control type between the proper control and the Office control.
I do not recall all the errors I received before figuring this out, but I do recall that code like this worked:
Public Sub ClearTagCombo(ByVal f As Form)
On Error GoTo fail
Dim cbCtl As Control
For Each cbCtl In f.Controls
If cbCtl.Name = "cbfields" Then
cbCtl.Text = cbCtl.Tag
ElseIf TypeOf cbCtl Is DataCombo Then
cbCtl.BoundText = cbCtl.Tag
End If
Next cbCtl
Exit Sub
fail:
MsgBox Err.Description, vbExclamation
End Sub
But this would not
Public Sub ClearTagCombo(ByVal f As Form)
On Error GoTo fail
Dim cbCtl As Control
For Each cbCtl In f.Controls
If TypeOf cbCtl = combobox Then
cbCtl.Text = cbCtl.Tag
ElseIf TypeOf cbCtl Is DataCombo Then
cbCtl.BoundText = cbCtl.Tag
End If
Next cbCtl
Exit Sub
fail:
MsgBox Err.Description, vbExclamation
End Sub
I beleive that VB interprets the second code to be referring to the VB combobox and determines that the actual control is some unknown.
Additionally, I was unable to set properties for the office control where they were different from the VB control.
If you can I would not use the office controls.
Trust me on this. I can screw things up with the best of them and have tried this. There are much better ways.
Terry (cyberbiker)