MartyConnelly
martyconnelly at shaw.ca
Mon May 1 15:29:30 CDT 2006
You may have the Form object still open after the close Set recLang = Nothing Set FrmF = Nothing Daniel Hurtubise wrote: >Hello everyone: > >This is my first post. Sorry It might be a bit rough...... > >Objective: To have a screen change it labels depending on language >selected. > >Situation: Labels are all successfully changed and application works >perfectly. HOWEVER: > when leaving the application MSACCESS.EXE does not close >out in > the task manager. This only happens if the translation >module is called. > >The code is inoffensive but I've been at it now for two days !!!! The >ghost being produced >leaves me believing that something is not closed properly. Any ideas? > >Form A: Calls a function which sits within a Module >' ######################################################### >' Form Open Event >' ######################################################### >Private Sub Form_Open(Cancel As Integer) > ' > ' Set Language to current form > ' > Call changeFormLanguage(glang, Me) >End Sub > > >Module Code: > >' ######################################################### >' This section will cycle every form for a language change >' ######################################################### >Public Function changeFormLanguage(strLang As String, strFormName As Form) > > Dim db As Database > Dim recLang As Recordset > Dim objAo As AccessObject > Dim objCP As Object > Dim FrmF As Form ' current form > Dim ctlc As Control ' current control > Dim strControlName As String ' name of control > Dim intControlType As Integer ' control type > Dim strLangField As String > > 'open the database and language recordset > Set db = CurrentDb() > Set recLang = db.OpenRecordset(wcs_LANGUAGE_TABLE) > recLang.Index = "PrimaryKey" > > Set FrmF = strFormName > > strLangField = IIf(strLang = "English", "Lbl_DescEn", "Lbl_DescFr") > With recLang > .Seek "=", strFormName, strFormName > > 'add or update the form in the language table > If .NoMatch Or IsNull(.Fields(strLangField)) Then > FrmF.Caption = " " > Else > FrmF.Caption = .Fields(strLangField) > End If > > 'now loop through the controls > For Each ctlc In FrmF.Controls > 'we are interested in the controls with captions > intControlType = ctlc.ControlType > If ControlHasCaption(intControlType) = True Then > 'find the control in the language table > strControlName = ctlc.Name > .Seek "=", strFormName.Name, strControlName > > 'add or update the control in the language table > If .NoMatch Or IsNull(.Fields(strLangField)) Then > ctlc.Caption = "" > Else > ctlc.Caption = .Fields(strLangField) > End If > End If > Next > End With > > 'close up > recLang.Close > db.Close >End Function > > > -- Marty Connelly Victoria, B.C. Canada