MarkH
lists at theopg.com
Fri Dec 17 14:19:38 CST 2004
Excellent... Thanks for that, so far I have not experienced any problems but I don't think I'll wait for something to go wrong... Thanks again Mark -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Ken Ismert Sent: 17 December 2004 17:32 To: 'Access Developers discussion and problem solving' Subject: RE: [AccessD] Multi-Instance Forms re-visited Jim, Mark, Francisco, >I believe Hwnd is unique as well. > >Jim See the Note in "hWnd Property", http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vb98/ht ml/v bprohwnd.asp What Microsoft is saying in this topic, and the Access Help topic, is that while the hWnd for a window will be unique, you can't count on it to keep the same value over time. So, if you key your form collection using hWnd, any function tries to find the form instance in the collection based on the current hWnd is not guaranteed to work. The hWnd will still be unique, it just may not be the same value you stored when you added the form to the collection. In one of my object form managers, I use a class module-level variable to guarantee a unique, stable ID: Private lIDCounter As Long Public Sub AddForm(rFrm As Access.Form) Dim sID As String lIDCounter = lIDCounter + 1 sID = CStr(lIDCounter) colForms.Add rFrm, sID rFrm.SetInstanceID sID End Sub Of course, each form participating in this scheme now needs to have a SetInstanceID method: Private sInstanceID As String Public Sub SetInstanceID(sID As String) sInstanceID = sID End Sub Now the form, when it is calling back to the managing object, can use its sInstanceID to identify itself. This is extra work, but do you want to be 99% sure your Form ID solution will work, or 100%? -Ken -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.805 / Virus Database: 547 - Release Date: 03/12/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.805 / Virus Database: 547 - Release Date: 03/12/2004