Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
  1. #16
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Keep in mind that global variable loses value if code hits an unhandled runtime error - TempVar does not. Also, textbox and query and macro can reference TempVar - not so with global variable.



    There are many examples of options provided. A quick web search should provide some.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  2. #17
    charly.csh is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Nov 2014
    Posts
    186
    Hi Micron
    I tried on this way but it didn't work, I don't if I'm doing something wrong

    I attached the example and maybe it can be easier to explain
    Example of Languages.zip

    I highly appreciate the help!

  3. #18
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    There is no need to use DLookup to retrieve ID. Include field in combobox RowSource. Combobox properties:

    RowSource: SELECT Id, [language] FROM Setlanguages_tbl ORDER BY [language];
    BoundColumn: 1
    ColumnCount: 2
    ColumnWidths: 0";2"

    Textbox and button not needed.

    Code for Setlanguages_Frm
    Code:
    Private Sub Languagedl_AfterUpdate()
    DoCmd.OpenForm "Login_Frm", , , , , , Me.Languagedl
    End Sub
    Code for Login_Form
    Code:
    Private Sub Form_Open(Cancel As Integer)
    
    Me.languagetxt.SetFocus
    
    Me.userlbl.Caption = DLookup("[" & Me.OpenArgs & "]", "[languages_tbl]", "[label]='userlbl'")
    Me.passwordlbl.Caption = DLookup("[" & Me.OpenArgs & "]", "[languages_tbl]", "[label]='passwordlbl'")
    Me.showpasswordlbl.Caption = DLookup("[" & Me.OpenArgs & "]", "[languages_tbl]", "[label]='showpasswordlbl'")
    
    End Sub
    An alternative to this code is to use textbox as "label" with expression:
    =DLookup("[" & [OpenArgs] & "]", "[languages_tbl]", "[label]='userlbl'")

    What is purpose of languagetxt textbox?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #19
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    Here's a different approach. It can be improved a bit but it might give you some ideas. Might be a good candidate for a custom Class.

    NOTE: I didn't use or changed your tables, forms, or object names so you'll have to adapt. I also used a single record Local settings table(keep it in the front end when you split the Db.) to remember the last selected language.

    For any label you want changed put "Lang" (no quotes) in the tag property of the label.

    in the Onload event of the form
    Code:
    Private Sub Form_Load()
    
        Dim ctl As Control
    
        For Each ctl In Me.Controls
        
            If ctl.Tag = "Lang" Then
            
                getLang ctl
                
            End If
            
        Next
        
    End Sub
    Code:
    Public Sub getLang(Lbl As Label)
    
    
        Dim LID As Integer
        Dim col As New Collection
    
    
        LID = DLookup("LangChoice", "tblLocalSettings")
    
    
        Dim db As DAO.Database
        Dim rs  As DAO.Recordset
        Dim SQL_Select  As String
    
    
        SQL_Select = "select * from tblLabelLanguage where strLabelName = """ & Lbl.Name & """"
    
    
        Set db = CurrentDb()
        Set rs = db.OpenRecordset(SQL_Select)
    
    
        With rs
     
            col.Add rs!Spanish
            col.Add rs!English
            col.Add rs!deutsch
            col.Add rs!Francais
     
        End With
     
        Lbl.Caption = col(LID)
     
    MyExit:
    
    
        rs.Close
        Set rs = Nothing
        Set db = Nothing
        Set col = Nothing
    
    End Sub
    Attached Files Attached Files
    Last edited by moke123; 09-29-2023 at 12:07 PM.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  5. #20
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    Here's another version as a custom class. It was relatively easy to convert to a class.
    Make sure you set a reference to Microsoft Scripting Runtime.

    All you need to do is add these lines of code to the form.
    As long as there is a corresponding label name in your table it will convert the language for the label.

    Code:
    Dim LS As clsLabels   'In the declarations section at top of module
    
    
    Private Sub Form_Load()
    
    
        Set LS = New clsLabels
    
    
        LS.initMyClass Me
        
    End Sub
    Edit: note that I just copied objects from the other version. I didn't delete the tag text, but it is not needed in this version
    Attached Files Attached Files
    Last edited by moke123; 09-29-2023 at 08:50 AM. Reason: added comment
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  6. #21
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    I'm getting a little carried away, but here's another version which will change labels as well as command button captions.
    Attached Files Attached Files
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  7. #22
    charly.csh is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Nov 2014
    Posts
    186
    Hi June_7
    Thank you! I have followed the advice and worked great!!

  8. #23
    charly.csh is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Nov 2014
    Posts
    186
    Hi moke123

    Thank you very much for the 3 examples!!!!! are great!!! with all of the them I have excellent ideas how to solve something like this!!!
    Highly appreciate your support and your examples!!!

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 12-21-2021, 07:44 PM
  2. Replies: 4
    Last Post: 08-04-2020, 12:13 AM
  3. Replies: 3
    Last Post: 11-29-2016, 10:03 AM
  4. Replies: 5
    Last Post: 01-30-2015, 02:45 PM
  5. unbound field
    By slimjen in forum Forms
    Replies: 9
    Last Post: 10-16-2013, 02:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums