Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Forms Classes and ActiveX Problem

Status
Not open for further replies.

robotman757

Programmer
Jan 3, 2003
14
US
Hello,

I have a large problem and have been racking my noodle trying to figure it out. I have a form in MS Access that has an ActiveX control on it. It has a name and some events. I have some classes that need to talk to this control. I vba code I assign a name as a New ControlX and can then reference the functions and propertis of this type of control. However, I can't set the control on the form to the name in code or the other way around.

Public goof AS goofctl (name and control to vba class code)

goofy_ctl = Name of control on the form

Set goof = Me.goofy_ctl
goof.functionA ....

I error at the Set line and can't talk to the control

Any ideas would be greatly appreciated
 
could you post the actual code, and the actual error message?
 
Public gCtl As glxCtl
Public CX As CXXX
(glxCtl is the registered name of the control and these comands are in a module that defines a lot of constants)

Private Sub Form_Load()
Set gCtl = Me.glxCtl1
End Sub
(glxCtl1 is the name of the control that is on the form (Form1)

If I type gCtl. then I get functions, but setting it to the actual control that the user sees returns a Runtime Error 13 Type Mismatch

Thanks
 
looks pretty straightforward to me; I have no idea why it wouldn't work.

What if you declare gCtl as an object and do late binding?
 
Not Sure exactly what you are saying, but declaring it this way saves a lot of typing since you get the happy box that comes up with all the functions and stuff. I thought it was a problem with VBA, but I don't know. The code for the form treats it like a regular access control because I can't assign it!! Argg!!! Thanks for the help. I do have opengl working on an Access form but I really want to get this control to work!!
 
hmm...
gotta love the happy box.

Maybe you can declare it as a control for coding purposes, then change the declaration at the last minute, as it were.

The late binding just means that Access doesn't know what kind of object it is until runtime, rather than at compile time, which is less efficient, but if it works, who cares?
 
Maybe the type mismatch can is caused by different types of value returned by gCtl control and variable you try to assign it.
What is the type returned by gCtl function and where do you assign it?
Do you still have an error if you replace gCtl by Me.glxCtl1 (or form refernce if outside it)?
 
If I try to use Me.glxCtl1, it only shows functions and properties of MS Access itself. The declaration gCtl As glxCtl allows the ability to use the functions of the control. I will try to declare it as an object to see if it will work. However, the purpose of the control was to avoid having to type so much!! Though I could write all the code and then change the declaration before running it...I will see
 
I finaly resolved by declaring it as the control during design time and then changing it to object before I run it. I am going to try a strtup function that will basically change the declaration with boolean algebra and if then statements!!

Thnaks for the help!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top