Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Classes Excel and Access - off topic

Hi,

I know this is off-topic, but have posted in microsoft.public.access.forms
with no success so I thought someone here might be able to point me in the
right direction.

The class module was an early example from J Walkenbach 'Excel 97 Power
Programming with VBA'. As you can see, tried to adapt this to Access forms,
but no luck.

Original Post


I am trying to automate the behaviour of many buttons in Access at once.
Something like a control array in VB. I can do this in Excel, but can't
figure out if there is an Access equivalent. Has anyone any pointers for me?

Firstly I built a class module called BtnClass with the following code;

Option Compare Database

' Declaration for Access
Public WithEvents ButtonGroup As CommandButton
' Declaration for Excel
' Public WithEvents ButtonGroup As MSForms.CommandButton

Private Sub ButtonGroup_Click()
MsgBox "You clicked - " & ButtonGroup.Name
End Sub

Then I built Form1, placed two button on it, and added the following code;

Dim Buttons() As New BtnClass

Private Sub Form_Load()
Dim ButtonCount As Integer
Dim ctl As Control

ButtonCount = 0

For Each ctl In Me.Controls
If TypeName(ctl) = "CommandButton" Then
ButtonCount = ButtonCount + 1
ReDim Preserve Buttons(1 To ButtonCount)
Set Buttons(ButtonCount).ButtonGroup = ctl
End If
Next ctl

End Sub

If I run the form, the Form_Load procedure works fine, but the button events
do not fire.

Now, this works in Excel except that in Excel a CommandButton is a member of
MSForms, whereas in Access CommandButtons are members of Access.

Is it possible to make this work in Access?

Ed Ferrero
http://edferrero.m6.net



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 593
Default Classes Excel and Access - off topic


Ed Ferrero wrote:
The class module was an early example from J Walkenbach 'Excel 97

Power
Programming with VBA'. As you can see, tried to adapt this to Access

forms,
but no luck.

Is it possible to make this work in Access?


I don't think so. See this recent thread:

http://tinyurl.com/5qxuu

It appears MS Access Forms' controls are not ActiveX, therefore you
cannot sink them in a class module using the WithEvents keyword.

Jamie.

--

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Classes alish Excel Discussion (Misc queries) 3 October 30th 07 01:03 PM
Advanced Excel Classes (Mostly for Charts) in Boston DQuint Excel Discussion (Misc queries) 0 May 23rd 06 04:16 PM
Anyone know good excel classes? ph8 Excel Discussion (Misc queries) 2 December 16th 05 03:16 PM
How can I use Excel to schedule students for classes? Mort 62 Excel Discussion (Misc queries) 1 September 8th 05 03:45 PM
Classes, and the For Each construct in Excel? Andy Excel Programming 1 August 3rd 04 02:29 PM


All times are GMT +1. The time now is 05:43 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"