John Bodin
jbodin at sbor.com
Fri Feb 8 13:33:43 CST 2013
Hi Stuart, Thanks for response. I follow what you are saying. In a little demo app link posted on Access-Programmers by ChrisO, I saw the code (below) for building a more generic function for handling/building a function to assign to an event. The referencing of me.activecontrol didn't cross my mind in your suggestion, makes sense though. So I understand about storing Button,Shift/X/Y in variables local to the form that you mention and then referencing them within routines in the form. My question relates to the "populate these in the MouseDown" comment. How do I generically reference these Button/Shift/X/Y variables from the Mouse Up/Down/Move events? If I were to create a procedure at Design time in the on mouse down event of a textbox control, it would be foo_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single). That's where I'm having a brain freeze, on how to reference these from a generic procedure - maybe from the storm kicking in here in the Boston area... Thanks, John ---snip Public Function MakeFunctionCall(ByVal strFunctionName As String, _ ParamArray vntArgList() As Variant) As String Dim lngElement As Long Dim strFunction As String ' The first argument is NOT optional. ' Add Function name and opening bracket. strFunction = "=" & strFunctionName & "(" ' All the remaining arguments are optional. ' Loop through argument range, if passed. For lngElement = LBound(vntArgList) To UBound(vntArgList) strFunction = strFunction & Chr$(34) & vntArgList(lngElement) & Chr$(34) & ", " Next lngElement ' Did we receive any arguments? ' If so, trim off trailing ", ". If Right$(strFunction, 2) = ", " Then strFunction = Left$(strFunction, Len(strFunction) - 2) End If ' Set return valve and closing bracket. MakeFunctionCall = strFunction & ")" End Function ---snip Message: 19 Date: Thu, 07 Feb 2013 06:47:50 +1000 From: "Stuart McLachlan" <stuart at lexacorp.com.pg> To: Access Developers discussion and problem solving <accessd at databaseadvisors.com> Subject: Re: [AccessD] Generic Procedure on form controls for Drag and Drop Message-ID: <5112C176.2253.23E47B62 at stuart.lexacorp.com.pg> Content-Type: text/plain; charset=US-ASCII Hi John, Welcome to the list. Instead of "=TxtBoxDblClick([Txt101])", you can just use ="TxtBoxDblClick()" and then in TxtBoxDblClick, just refer to Me.ActiveControl. You can do the same with your other functions. You can make your Up/Down/Move functions even more generic you using something like: Select Case Left$(me.activeControl.Name,3) Case "txt" ' It's a text box ... Case "cbo" 'It's a combobox ... You can store Button,Shift/X/Y in variables local to the form Dim intBtn As Integer Dim sngX As Single Dim sngY As Single Dim intShift As Integer and populate these in the MouseDown > > New to this list and need some guidance on a form I've developed (I posted > this on LinkedIn and got a few links with good information, but still having > issues). > > > > I have a grid of many text boxes on a form in an Access 2003 app that I fill > from a table upon opening the form as well as when the user changes a date > box. I add some generic procedure calls on the fly to each text box where I > pass the control to the generic function (for instance, I'll add a > double-click event to text box "Txt101" as "=TxtBoxDblClick([Txt101])". This > will pass the control to my function TxtBoxDblClick so I can react to it.) > This all works fine for all text boxes and I reference just one (same) > routine for each control. > > I'm trying to experiment with Drag and Drop and found some code that I can > get to work if at Design time, I add three event procedures to a text box > control (Mouse Down/Up/Move). If I do this to two different controls, > creating 3 event procedures for each at design time, I can successfully drag > and drop between the two controls. So the drag and drop code looks like it > works. > > My problem is, I want to have 3 generic routines like my TxtBoxDblClick > function, that I can add on the fly to the On Mouse Down/Up/Move events and > I can't figure out the syntax and/or code to make this happen. I can add the > custom Functions no problem, but I know I need to be able to deal with the > Button, Shift, X & Y parameters somehow. I can pass the control to the > custom function, but am unable to reference the Button, Shift, X & Y > parameters. I'm guessing I'll need to create some type of class possibly? If > so, can someone provide some sample code on how to do this what the calls > would be? Thanks for any ideas. John > > > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > ------------------------------ Message: 20 Date: Wed, 6 Feb 2013 18:54:03 -0500 From: jack drawbridge <jackandpat.d at gmail.com> To: Access Developers discussion and problem solving <accessd at databaseadvisors.com> Subject: Re: [AccessD] Generic Procedure on form controls for Drag and Drop Message-ID: <CAKvidAuqO1stgTkSp9ZTQtvpaTjs6H8FTGEGpkv3WbstR6XMrg at mail.gmail.com> Content-Type: text/plain; charset=windows-1252 John, I found another link that is more focused on your drag and Drop. http://www.access-programmers.co.uk/forums/showthread.php?t=238669 >From post #5 "I really do not have a meaning of beginner/intermediate but do have some classes broken down into minimalistic form on my SkyDrive in my signature. It?s a developmental sequence of classes used for ?drag and drop? running:- Drag Drop -> Drag Drop Resize -> Drag Drop Resize GridSnap -> Drag DropResize GridSnap Save. Some end applications for drag and drop, also on my SkyDrive, are:- Drag Floor Plan, Drag Polygons, Z Order Bound Objects and Drag and DropChess." Good luck On Wed, Feb 6, 2013 at 1:55 PM, John Bodin <jbodin at sbor.com> wrote: > Hello, > > > > New to this list and need some guidance on a form I've developed (I posted > this on LinkedIn and got a few links with good information, but still > having > issues). > > > > I have a grid of many text boxes on a form in an Access 2003 app that I > fill > from a table upon opening the form as well as when the user changes a date > box. I add some generic procedure calls on the fly to each text box where I > pass the control to the generic function (for instance, I'll add a > double-click event to text box "Txt101" as "=TxtBoxDblClick([Txt101])". > This > will pass the control to my function TxtBoxDblClick so I can react to it.) > This all works fine for all text boxes and I reference just one (same) > routine for each control. > > I'm trying to experiment with Drag and Drop and found some code that I can > get to work if at Design time, I add three event procedures to a text box > control (Mouse Down/Up/Move). If I do this to two different controls, > creating 3 event procedures for each at design time, I can successfully > drag > and drop between the two controls. So the drag and drop code looks like it > works. > > My problem is, I want to have 3 generic routines like my TxtBoxDblClick > function, that I can add on the fly to the On Mouse Down/Up/Move events and > I can't figure out the syntax and/or code to make this happen. I can add > the > custom Functions no problem, but I know I need to be able to deal with the > Button, Shift, X & Y parameters somehow. I can pass the control to the > custom function, but am unable to reference the Button, Shift, X & Y > parameters. I'm guessing I'll need to create some type of class possibly? > If > so, can someone provide some sample code on how to do this what the calls > would be? Thanks for any ideas. John > > > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > ------------------------------ Message: 21 Date: Thu, 7 Feb 2013 15:38:37 +1100 From: "Darren" <darren at activebilling.com.au> To: "'Access Developers discussion and problem solving'" <accessd at databaseadvisors.com> Subject: Re: [AccessD] Generic Procedure on form controls for Drag and Drop Message-ID: <070401ce04ed$00bbc8f0$02335ad0$@activebilling.com.au> Keywords: To be Addressed Content-Type: text/plain; charset="us-ascii" Hi John, Welcome to the list. We have a webpage too. http://www.databaseadvisors.com On that Webpage is some code samples. One in particular that shows one way to accomplish some elements of Drag and Drop in Access. Check it out at: http://www.databaseadvisors.com/downloads.asp And look for "Drag and Drop". Hope it's useful. Darren -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of John Bodin Sent: Thursday, 7 February 2013 5:56 AM To: accessd at databaseadvisors.com Subject: [AccessD] Generic Procedure on form controls for Drag and Drop Hello, New to this list and need some guidance on a form I've developed (I posted this on LinkedIn and got a few links with good information, but still having issues). I have a grid of many text boxes on a form in an Access 2003 app that I fill from a table upon opening the form as well as when the user changes a date box. I add some generic procedure calls on the fly to each text box where I pass the control to the generic function (for instance, I'll add a double-click event to text box "Txt101" as "=TxtBoxDblClick([Txt101])". This will pass the control to my function TxtBoxDblClick so I can react to it.) This all works fine for all text boxes and I reference just one (same) routine for each control. I'm trying to experiment with Drag and Drop and found some code that I can get to work if at Design time, I add three event procedures to a text box control (Mouse Down/Up/Move). If I do this to two different controls, creating 3 event procedures for each at design time, I can successfully drag and drop between the two controls. So the drag and drop code looks like it works. My problem is, I want to have 3 generic routines like my TxtBoxDblClick function, that I can add on the fly to the On Mouse Down/Up/Move events and I can't figure out the syntax and/or code to make this happen. I can add the custom Functions no problem, but I know I need to be able to deal with the Button, Shift, X & Y parameters somehow. I can pass the control to the custom function, but am unable to reference the Button, Shift, X & Y parameters. I'm guessing I'll need to create some type of class possibly? If so, can someone provide some sample code on how to do this what the calls would be? Thanks for any ideas. John -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com ------------------------------ Message: 22 Date: Thu, 7 Feb 2013 03:28:32 -0500 From: John Colby <jwcolby at gmail.com> To: Access Developers discussion and problem solving <accessd at databaseadvisors.com> Subject: Re: [AccessD] Generic Procedure on form controls for Drag and Drop Message-ID: <CAA_iUE-0gou8viNeu7swomVSqsUWqcc3hZ8W-Cr9ZoXhW96TuQ at mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 This sounds like the perfect use for a class. A class can Sync events. A class is used when you have to do the same thing over and over. The event sinks you mention would be embedded in the class and the code to process the event sinks would be embedded in the class. I left my computer at work so I can't look at this right now. In the morning I will respond further. On Feb 6, 2013 1:56 PM, "John Bodin" <jbodin at sbor.com> wrote: > Hello, > > > > New to this list and need some guidance on a form I've developed (I posted > this on LinkedIn and got a few links with good information, but still > having > issues). > > > > I have a grid of many text boxes on a form in an Access 2003 app that I > fill > from a table upon opening the form as well as when the user changes a date > box. I add some generic procedure calls on the fly to each text box where I > pass the control to the generic function (for instance, I'll add a > double-click event to text box "Txt101" as "=TxtBoxDblClick([Txt101])". > This > will pass the control to my function TxtBoxDblClick so I can react to it.) > This all works fine for all text boxes and I reference just one (same) > routine for each control. > > I'm trying to experiment with Drag and Drop and found some code that I can > get to work if at Design time, I add three event procedures to a text box > control (Mouse Down/Up/Move). If I do this to two different controls, > creating 3 event procedures for each at design time, I can successfully > drag > and drop between the two controls. So the drag and drop code looks like it > works. > > My problem is, I want to have 3 generic routines like my TxtBoxDblClick > function, that I can add on the fly to the On Mouse Down/Up/Move events and > I can't figure out the syntax and/or code to make this happen. I can add > the > custom Functions no problem, but I know I need to be able to deal with the > Button, Shift, X & Y parameters somehow. I can pass the control to the > custom function, but am unable to reference the Button, Shift, X & Y > parameters. I'm guessing I'll need to create some type of class possibly? > If > so, can someone provide some sample code on how to do this what the calls > would be? Thanks for any ideas. John > > > > -- > 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 End of AccessD Digest, Vol 120, Issue 4 ***************************************