Mark A Matte
markamatte at hotmail.com
Wed Sep 10 07:51:46 CDT 2008
Darren,
I done something similar...but not with buttons. So I modified to see if I could get what you need. I used a form,subform, and table. I got the idea from a sample Candace Tripp had on her site years ago. There is no error handling...just code.
Let me know if you have any questions or need a sample mdb.
Thanks,
Mark A. Matte
Here is the code for each form:
SubForm: sfrmMyButtons
Option Compare Database
Function ImClicked()
Dim CNM
Dim ctlCurrentControl As Control
Set ctlCurrentControl = Screen.ActiveControl
CNM = Right(ctlCurrentControl.Name, Len(ctlCurrentControl.Name) - 4)
If Me("tgl_" & CNM) = 0 Or IsNull(Me("tgl_" & CNM)) = True Then
Me("tgl_" & CNM) = -1
Me("lb1_" & CNM).Visible = False
Me("lb2_" & CNM).Visible = True
Else
Me("tgl_" & CNM) = 0
Me("lb1_" & CNM).Visible = True
Me("lb2_" & CNM).Visible = False
End If
End Function
Main Form: frmMakeButton
Function MakeButtons()
Dim dbs As Database, rst As Recordset, intI As Integer
Dim ctlLabel As Control, ctlText As Control, ctlToggle As Control, ctlButton As Control
Dim intDataX As Integer, intDataY As Integer
Dim intLabelX As Integer, intLabelY As Integer
DoCmd.OpenForm "sfrmMyButtons", acDesign
Dim ctl As Control
LoopAgain:
For Each ctl In Forms!sfrmMyButtons.Controls
Dim test
DeleteControl "sfrmMyButtons", ctl.Name
Next ctl
If Forms!sfrmMyButtons.Controls.Count> 0 Then GoTo LoopAgain
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("SELECT Table2.emails FROM Table2 WHERE Table2.Group= '" & [Forms]![frmMakeButton]![Combo3] & "';")
rst.MoveLast
rst.MoveFirst
intLabelX = 100
intLabelY = 100
intDataX = 1000
intDataY = 100
For intI = 1 To rst.RecordCount
'********************************
Set ctlToggle = CreateControl("sfrmMyButtons", acToggleButton, , "", "", intLabelX, intLabelY, 2000, 500)
ctlToggle.Name = "tgl_" & rst!emails
ctlToggle.TabStop = 0
ctlToggle.Enabled = False
Set ctlLabel = CreateControl("sfrmMyButtons", acLabel, , "", "66666666662222222000000", intLabelX, intLabelY, 2000, 500)
ctlLabel.Name = "lb1_" & rst!emails
ctlLabel.Caption = rst!emails
ctlLabel.TextAlign = 2
Set ctlLabel = CreateControl("sfrmMyButtons", acLabel, , "", "66666666662222222000000", intLabelX, intLabelY + 100, 2000, 500)
ctlLabel.Name = "lb2_" & rst!emails
ctlLabel.Caption = rst!emails
ctlLabel.TextAlign = 2
ctlLabel.Visible = False
Set ctlButton = CreateControl("sfrmMyButtons", acCommandButton, , "", "66666666662222222000000", intLabelX, intLabelY, 2000, 500)
ctlButton.Visible = True
ctlButton.Name = "cmd_" & rst!emails
ctlButton.Transparent = True
ctlButton.OnMouseDown = "=imClicked()"
ctlButton.OnMouseUp = "=imClicked()"
intLabelY = intLabelY + 500
'********************************
rst.MoveNext
Next intI
Set dbs = Nothing
Set rst = Nothing
DoCmd.Close acForm, "sfrmMyButtons", acSaveYes
End Function
Private Sub Combo3_AfterUpdate()
Me!sfrmMyButtons.SourceObject = ""
MakeButtons
Me!sfrmMyButtons.SourceObject = "sfrmMyButtons"
End Sub
> From: darren at activebilling.com.au
> To: accessd at databaseadvisors.com
> Date: Tue, 9 Sep 2008 09:52:18 +1000
> Subject: Re: [AccessD] A2003: Table Driven button list on Continuous Forms
>
> Hi Kath
>
> Thanks for the reply
> I just wanted to build a list of buttons (that grows and shrinks)on a continuous
> form for each of our clients. Clients are selected by tabs and the list of
> buttons is 'built' on each tab click (In a sub form). The table is a list of
> applications each client has and I want a button list of their applications and
> I wanted the caption on the button and the list of buttons to be table driven.
>
> That ain't gonna work. So I used a transparent text box over the no caption
> button that looked OK until you click it. Then the mouse simply moves to the
> text box and the text of 'the button' is selected. Then I wanted the 'look' of a
> button being pushed and look of a button being released when the mouse got to
> this transparent text box. Too tricky
>
> I gave up - can't easily be done and I have already used an inappropriate amount
> of time chasing the 'look'
>
> Darren
>
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Kath Pelletti
> Sent: Tuesday, 9 September 2008 9:10 AM
> To: Access Developers discussion and problem solving
> Subject: Re: [AccessD] A2003: Table Driven button list on Continuous Forms
>
> Darrren -
>
> I'm not sure that I *entirely* understand what you are trying to do, but if
> you want bound controls which look like rounded buttons, then can draw a
> rounded button (in Word or PPoint), and then sit the bound control on top of
> it (text box) and set it's back style to transparent.
>
> Why do you need a mouse down/up event?
>
> kath
>
> ----- Original Message -----
> From: "Darren D"
> To: "'Access Developers discussion and problem solving'"
>
> Sent: Monday, September 08, 2008 10:24 PM
> Subject: [AccessD] A2003: Table Driven button list on Continuous Forms
>
>
>> Hi All
>>
>>
>>
>> I have a table of application names that will grow and shrink with many
>> fields
>> but the 2 of interest are.
>>
>> APPID = AutoNumber and AppName = Text
>>
>>
>>
>> I want a continuous form to have a button for each item in that table.
>>
>> Trouble is It is a bit tricky to get the caption for each button to = the
>> AppName for each record in the table
>>
>> I can 'fake' it using labels but if I write a routine to simulate a mouse
>> down
>> and mouse up to mimic raises and depressions then
>>
>> all the labels that are simulated buttons on the form depress and raise at
>> the
>> same time
>>
>> Besides I would prefer to have the 'rounded' look to the buttons simply to
>> match
>> the rest of my screen design
>>
>>
>>
>> I know many people have done this sort of thing before - But how have you
>> managed it on a continuous form driven by a table
>>
>>
>>
>> Many thanks in advance
>>
>>
>>
>> Darren
>>
>>
>>
>> --
>> AccessD mailing list
>> AccessD at databaseadvisors.com
>> http://databaseadvisors.com/mailman/listinfo/accessd
>> Website: http://www.databaseadvisors.com
>>
>
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
_________________________________________________________________
See how Windows connects the people, information, and fun that are part of your life.
http://clk.atdmt.com/MRT/go/msnnkwxp1020093175mrt/direct/01/