Toggling combo box language (value list) using a command button (1 Viewer)

docxyz

Registered User.
Local time
Today, 12:36
Joined
Nov 2, 2014
Messages
56
Hi everybody, first to say I appreciate all the help and replies that genius members had provided me with, this project wouldnt be perfect without your help, and Im sorry if I ask so much questions, but I found this forum as a gold mine to me with this number of kind and nice ppl.

Now I have "tbl_organs" with three columns "organNameLatin" and "organNameArabic" as body organs names in latin and its arabic translation,and "bodySystem" which contains body sestems "digestive, respiratory..." in Latin only, and "frm_visit" as a form for recording visit data, I added unbound combo box "cbo_organ" with raw source "tbl_organs", I addedd two command buttons "cmd_En" and "cmd_Ar" to convert the combo box value from english to arabic, I mean cmd_En for showing combo box with two columns "organNameLatin" and "bodySystem",for cmd_Ar will show "bodySystem" and "organNameArabic" , the value of "cbo_organ" then used with another field for populating a txt box, i used this code for onClick event for "cmd_En" :

Me. cbo_Organ = "select distinct bodySystem, organLatinName" & _
"from tbl_organs " & _
" order by bodySystem;"

And for cmd_Ar :

Me. cbo_Organ = "select distinct bodySystem, organArabicName" & _
"from tbl_organs " & _
" order by bodySystem;"

By pressing cmd_En nothing changes and combo box still showing three columns, also the final result is populating bodySystem in final txt box instead of organ name, I dont know if properties of combo box "cbo_organs" like column count and row source have effect on this or not, and if I should determine row source of combo box from the beginning or not ?
NB: bodySystem is in one language only which is Latin, the form is unbound, combo and final txt box are unbound. I appreciate your help.
 

jdraw

Super Moderator
Staff member
Local time
Today, 05:36
Joined
Jan 23, 2006
Messages
15,379
Can you post a copy of your database, or a condensed version with only some records and nothing confidential?


Here is some code that sits behind the attached form
Code:
Option Compare Database

Private Sub Form_Open(Cancel As Integer)
10    Debug.Print "value of me.frame2 On Open is " & Me.Frame2
End Sub

Private Sub Frame2_AfterUpdate()
      Dim SQL As String
10    Debug.Print "value of me.frame2 after update is " & Me.Frame2
20    SQL = "select * from (SELECT EntryEF.id, EntryEF.entry, EntryEF.langCode " _
      & "FROM EntryEF Union select  0,'<Please Select>',1 from entryEF " _
      & " Union select  0,'<Choississez>',2 from entryEF " _
      & " UNION select  0,'<OndellexChermigo>',3 from entryEF) where langCode = " _
      & Forms!frmEntriesByLang.Frame2 & " ORDER BY id;"
30    Debug.Print SQL
40    Me.Combo0.Value = ""
50    Me.Combo0.RowSourceType = "Table/Query"
60    Me.Combo0.RowSource = SQL
70    Me.Combo0.Requery
End Sub
 

Attachments

  • FormDesignView.jpg
    FormDesignView.jpg
    24.3 KB · Views: 82
  • SelectEnglish.jpg
    SelectEnglish.jpg
    90.6 KB · Views: 74
  • SelectedFrench.jpg
    SelectedFrench.jpg
    92.2 KB · Views: 74
  • SelectEsperanto.jpg
    SelectEsperanto.jpg
    92 KB · Views: 74

docxyz

Registered User.
Local time
Today, 12:36
Joined
Nov 2, 2014
Messages
56
Can you post a copy of your database, or a condensed version with only some records and nothing confidential?


Here is some code that sits behind the attached form
Code:
Option Compare Database

Private Sub Form_Open(Cancel As Integer)
10    Debug.Print "value of me.frame2 On Open is " & Me.Frame2
End Sub

Private Sub Frame2_AfterUpdate()
      Dim SQL As String
10    Debug.Print "value of me.frame2 after update is " & Me.Frame2
20    SQL = "select * from (SELECT EntryEF.id, EntryEF.entry, EntryEF.langCode " _
      & "FROM EntryEF Union select  0,'<Please Select>',1 from entryEF " _
      & " Union select  0,'<Choississez>',2 from entryEF " _
      & " UNION select  0,'<OndellexChermigo>',3 from entryEF) where langCode = " _
      & Forms!frmEntriesByLang.Frame2 & " ORDER BY id;"
30    Debug.Print SQL
40    Me.Combo0.Value = ""
50    Me.Combo0.RowSourceType = "Table/Query"
60    Me.Combo0.RowSource = SQL
70    Me.Combo0.Requery
End Sub

Hi jdraw, thank you for your reply, I will post sample database and screenshots, the examples you provided are very nice, but it is not what I'm asking for, thank you.
 
Last edited:

smig

Registered User.
Local time
Today, 12:36
Joined
Nov 25, 2009
Messages
2,209
can you explain in simple English (Not trms of Access - Combo, columns, textbox...) what you want to get.
 

nanscombe

Registered User.
Local time
Today, 10:36
Joined
Nov 12, 2011
Messages
1,082
I believe you just need to add the "Rowsource" method to your code.

And for cmd_En :

Code:
Private Function cmd_En_Click()
  Me.cbo_Organ.[COLOR="Red"]Rowsource[/COLOR] = "select distinct bodySystem, organLatinName" & _
  "from tbl_organs " & _
  " order by bodySystem;"
End Function

And for cmd_Ar :

Code:
Private Function cmd_Ar_Click()
  Me.cbo_Organ.[COLOR="Red"]Rowsource[/COLOR] = "select distinct bodySystem, organArabicName" & _
  "from tbl_organs " & _
  " order by bodySystem;"
End Function
 
Last edited:

docxyz

Registered User.
Local time
Today, 12:36
Joined
Nov 2, 2014
Messages
56
I believe you just need to add the "Rowsource" method to your code.

And for cmd_En :

Code:
Private Function cmd_En_Click()
  Me.cbo_Organ.[COLOR="Red"]Rowsource[/COLOR] = "select distinct bodySystem, organLatinName" & _
  "from tbl_organs " & _
  " order by bodySystem;"
End Function

And for cmd_Ar :

Code:
Private Function cmd_Ar_Click()
  Me.cbo_Organ.[COLOR="Red"]Rowsource[/COLOR] = "select distinct bodySystem, organArabicName" & _
  "from tbl_organs " & _
  " order by bodySystem;"
End Function

Yup, this seems logic, I will give a try and tell you, thank you sir.
 

docxyz

Registered User.
Local time
Today, 12:36
Joined
Nov 2, 2014
Messages
56
I believe you just need to add the "Rowsource" method to your code.

And for cmd_En :

Code:
Private Function cmd_En_Click()
  Me.cbo_Organ.[COLOR="Red"]Rowsource[/COLOR] = "select distinct bodySystem, organLatinName" & _
  "from tbl_organs " & _
  " order by bodySystem;"
End Function

And for cmd_Ar :

Code:
Private Function cmd_Ar_Click()
  Me.cbo_Organ.[COLOR="Red"]Rowsource[/COLOR] = "select distinct bodySystem, organArabicName" & _
  "from tbl_organs " & _
  " order by bodySystem;"
End Function

Hi nanscombe, very happy new year, I'm so sorry for not replying telling you about the result, yes" rowsourse" did solved the problem, just like that, thank you very much, you are a part of this project :)
 

Users who are viewing this thread

Top Bottom