I can't select value from a combobox why? (1 Viewer)

bmkol

Member
Local time
Today, 23:21
Joined
Dec 2, 2021
Messages
39
I have a form (Hebrew) with few comboboxes all of them working good except one that not letting me selecting a value and I can't understand the problem
Here are 2 screen shuts the first one is where I want to select and the second one is after I selected

1.
1639518122792.png


2.
1639518196918.png


It give me just the first one all the time

Please help
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 16:21
Joined
May 21, 2018
Messages
8,525
What is the control source? Is the field locked?
 

bmkol

Member
Local time
Today, 23:21
Joined
Dec 2, 2021
Messages
39
What is the control source? Is the field locked?
It doesn't have a control source becuase it based on vba code

1639518711340.png
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:21
Joined
Oct 29, 2018
Messages
21,453
Sounds like the bound column may have duplicate values. Does it?
 

bastanu

AWF VIP
Local time
Today, 13:21
Joined
Apr 13, 2010
Messages
1,402
If the combo's are used to filter or search records on the form they should be unbound otherwise you will be editing the (first) record with every change.
EDIT: too late, I see you have them unbound. Would you please show us the VBA code that sets the row source?

Cheers,
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:21
Joined
Oct 29, 2018
Messages
21,453
Sorry, that's not what I meant. For example, typically, a combobox would display one column but actually have a hidden one, which is the bound column. If so, I was saying perhaps that hidden column contains duplicate values, like this:

1, Item1
1, Item2
1, Item3
etc...
 

bmkol

Member
Local time
Today, 23:21
Joined
Dec 2, 2021
Messages
39
Sorry, that's not what I meant. For example, typically, a combobox would display one column but actually have a hidden one, which is the bound column. If so, I was saying perhaps that hidden column contains duplicate values, like this:

1, Item1
1, Item2
1, Item3
etc...
It has one hidden column (the id) ... here is the vba code:

strSqlPerek = "SELECT tblPasuk.ParashaId, tblPasuk.PasukNum FROM tblPasuk WHERE (tblPasuk.ParashaId=" & Form_frmPsukim.cmbParasha.Value & ") AND " & " (tblPasuk.PerekNum='" & Form_frmPsukim.cmbPerek & "') "
Me.cmbPasuk.RowSource = strSqlPerek
Me.cmbPasuk.Requery
Me.cmbPasuk = Me.cmbPasuk.ItemData(0)
 

bmkol

Member
Local time
Today, 23:21
Joined
Dec 2, 2021
Messages
39
Can we see the vba code that is the underlying code?
here it is:

strSqlPerek = "SELECT tblPasuk.ParashaId, tblPasuk.PasukNum FROM tblPasuk WHERE (tblPasuk.ParashaId=" & Form_frmPsukim.cmbParasha.Value & ") AND " & " (tblPasuk.PerekNum='" & Form_frmPsukim.cmbPerek & "') "
Me.cmbPasuk.RowSource = strSqlPerek
Me.cmbPasuk.Requery
Me.cmbPasuk = Me.cmbPasuk.ItemData(0)
 

bastanu

AWF VIP
Local time
Today, 13:21
Joined
Apr 13, 2010
Messages
1,402
So it looks like theDBGuy was right, you are selecting only one ID for your bound (hidden) column: =" & Form_frmPsukim.cmbParasha.Value
And you don't need the requery after you set the row source. And why select the first entry?
 

bmkol

Member
Local time
Today, 23:21
Joined
Dec 2, 2021
Messages
39
So it looks like theDBGuy was right, you are selecting only one ID for your bound (hidden) column: =" & Form_frmPsukim.cmbParasha.Value
And you don't need the requery after you set the row source. And why select the first entry?
But I do have 2 columns as in the picture when the first one is hidden

1639520185067.png
 

bmkol

Member
Local time
Today, 23:21
Joined
Dec 2, 2021
Messages
39
O.K ... I found the problem ... from what

bastanu asked ... I changed the bound to 2 and it is ok now.​

1639520461462.png



Thanks to evryone that tried to help
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:21
Joined
Oct 29, 2018
Messages
21,453

theDBguy I want to thank you too your answer is exactly the problem I had, but I was stupid not to understand it. :unsure::unsure:

No worries. The main thing is that you were able to fix it. Cheers!
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 16:21
Joined
Feb 19, 2002
Messages
43,213
You are using the combo itself as criteria for its RowSource. That doesn't sound right.

PS - you can just put the query into the RowSource. You don't need code to load it.
 

Users who are viewing this thread

Top Bottom