Drew Wutka
DWUTKA at Marlow.com
Wed Mar 5 12:42:30 CST 2008
http://www.marlow.com/ComboExample.mdb I have three tables, three forms, one module, and two class modules. Two of the tables (tblDataOne, tblDataTwo) are just one field tables (field is Data) for demoing data in the combos. The third table is tblComboboxSQL which has a Form, Control and SQL field. The module has the callback function and the global declaration for ComboRecordsets. ComboRecordsets is a class that 'holds' the recordsets used for the comboboxes. The three forms all have a combo box that runs off of the callback function. The only added code to the forms is on the unload event, the forms 'clear' their combo's recordsets from the global ComboRecordsets object. frmOne shows data from tblDataOne, frmTwo shows data from tblDataTwo, and frmThree shows data from both tables. Each has a record in the tblComboBoxSQL table. frmOne also has a button, that sets an ADODB recordset to cmbTest1. Note that the recordset it uses has two fields (just pulls both fields from both tables, but not as a union). If you open frmOne, it's combo will list One Two Three and Four. Click the button, and now that combo will have all the combinations between tblDataOne and tblDataTwo, and will now also have 2 columns. The key here is that ComboRecordsets stores a recordset keyed off of the form (actually parent, if this was a combobox on a subform). The callback function then works off the recordset stored there by feeding the parent and control name to the ComboRecordsets object from the fld Object (one of the arguments in the callback function). Drew -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby Sent: Wednesday, March 05, 2008 10:29 AM To: 'Access Developers discussion and problem solving' Subject: Re: [AccessD] using ADO to populate combos - wasRE:Error3048Cannotopen any more databases Have you ever done this? Inside of the call back function was a static array where the data for that specific control was placed. Thus each callback was specific to the control passed in. I tried doing this and failed. Do you have code demonstrating what you are thinking about? John W. Colby Colby Consulting www.ColbyConsulting.com -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Drew Wutka Sent: Wednesday, March 05, 2008 11:12 AM To: Access Developers discussion and problem solving Subject: Re: [AccessD] using ADO to populate combos - was RE:Error3048Cannotopen any more databases That's not necessary, to write a function for each control. One of the arguments of that control is the control itself. So you could create one function, in a module, that would be your 'global' callback function. What I would recommend would be to create a class that would handle recordset objects, and in your callback function pull the appropriate recordset from that class based on the control argument that is passed to the callback function. Drew -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby Sent: Wednesday, March 05, 2008 9:17 AM To: 'Access Developers discussion and problem solving' Subject: Re: [AccessD] using ADO to populate combos - was RE: Error3048Cannotopen any more databases Long ago I tried using call back functions and the only way I could figure out to do it was write a callback for each object. That just doesn't work when you want to implement this easily and automatically system wide - five hundred different combos. John W. Colby Colby Consulting www.ColbyConsulting.com -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Drew Wutka Sent: Wednesday, March 05, 2008 10:06 AM To: Access Developers discussion and problem solving Subject: Re: [AccessD] using ADO to populate combos - was RE: Error 3048Cannotopen any more databases Use a callback function. Drew -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby Sent: Wednesday, March 05, 2008 8:23 AM To: 'Access Developers discussion and problem solving' Subject: [AccessD] using ADO to populate combos - was RE: Error 3048 Cannotopen any more databases I was under the perhaps naive belief that with Access 2000 and greater, a combo could be populated by an ADO recordset, i.e. it's rowsource property could be an ado recordset. When I go out and look, I am running into methods that build up a string and the row source type is set to value list. That is a rather useless solution in the majority of cases since the max limit of characters in the list is around 2000. Is it in fact possible to make the rowsource an ADO recordset or am I delusional? If possible, how is it done? Example code would be nice. John W. Colby Colby Consulting www.ColbyConsulting.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com The information contained in this transmission is intended only for the person or entity to which it is addressed and may contain II-VI Proprietary and/or II-VI Business Sensitive material. If you are not the intended recipient, please contact the sender immediately and destroy the material in its entirety, whether electronic or hard copy. You are notified that any review, retransmission, copying, disclosure, dissemination, or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. -- 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 The information contained in this transmission is intended only for the person or entity to which it is addressed and may contain II-VI Proprietary and/or II-VI Business Sensitive material. If you are not the intended recipient, please contact the sender immediately and destroy the material in its entirety, whether electronic or hard copy. You are notified that any review, retransmission, copying, disclosure, dissemination, or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. -- 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 The information contained in this transmission is intended only for the person or entity to which it is addressed and may contain II-VI Proprietary and/or II-VI Business Sensitive material. If you are not the intended recipient, please contact the sender immediately and destroy the material in its entirety, whether electronic or hard copy. You are notified that any review, retransmission, copying, disclosure, dissemination, or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited.