David McAfee
DMcAfee at haascnc.com
Tue Jul 22 19:42:28 CDT 2003
Yes, Charlotte sent me some sample code which helped out a bunch! Does anyone know how to use the intrinsic Constant "acLBGetFormat"? I figure you simply do a select case on the column, but how do you return the value? Case acLBGetFormat 'call 7 'return the formatting info for the row/column Select Case lngCol Case 4, 5 'I want there to be shown as currency 'varretval= CCur(varretval) '? End Select 'Case lngCol Help sucks. Its tells you what the constants are, but not how to use them :( -----Original Message----- From: Jim Pawson David, These list filling functions are pretty trivial once you've got one working. So don't panic, just chill! The acLBInitialize gets called when your form opens (and also each time you explicitly requery the list). So that's your one and only opportunity to grab and retain the data that goes in your listbox. Choose your favourite method. You could have a module-scope recordset. You could have a static ADO disconnected recordset. You could use the good old-fashioned dynamic array. Or a collection. Etc... In your case, you just enter code in the acLBInitialize case that: - Opens your recordset from your other db - Stores the contents so you can easily get at them whenever you need to during the lifetime of the listbox. You already know the column count, so I'd guess the easiest thing would be to declare a static dynamic array. static savarListEntries() as variant In the acLBInitialize case, open the recordset and movelast to be sure you have a rowcount. Redim your array accordingly. Populate your array from your recordset. (Again, using your favourite technique. Don't forget there are methods of some recordsets that return the data in an array in one hit.) In other cases of the 'code' argument to your callback function, you'll need to supply: - the number of rows in your list - which you can get as Ubound( savarListEntries) - LBound( savarListEntries) + 1 - the number of columns in your list - which is 13 (BIG LIST!!) - the actual entry for a specific row,column in your list which you do by returning the appropriate cell from your array. There are other codes you need to handle too,but they are all fairly trivial and covered elsewhere. The *examples* in Help are pretty good, as are the samples in all the standard references. You CAN use a Stored Proc to drive a listbox but, if your data is in some weird temporary .mdb you may well be better persisting with your list filling. I don't think it's relevant here, but you can even use a Stored Proc that needs a parameter from another control on your form. The obvious way is to set the RowSource to an Exec statement where you dynamically change the statement to include its argument. But there's also a backdoor where you use the Stored Proc's parameter name as the name of the control supplying the parameter. (That makes sense when you know what it means. I'm a bit worried about it otherwise!!!) jim -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/ms-tnef Size: 3612 bytes Desc: not available URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030722/cb337683/attachment.bin>