Solved VBA returns record number, not value (1 Viewer)

DanSingleton

New member
Local time
Today, 05:56
Joined
Apr 2, 2020
Messages
10
Hi all, and if you can....HELP!

I have a combobox that is auto populated based on 2 other combo boxes. I select department and team number, and it returns a filtered combobox (Combo47) with the results, which is fine.

From the resulting combobox, I want to use the value of the selected result within that box in a query. I tested the result (The combobox shows my name in it) but when I run the below code, it returns " 1 " (the ID number of the autoindexing field). If I select another person, it returns their ID field number.

Can anyone popint me in the right direction please? Further information available on request

Code:
Dim getnm As String
    
getnm = Me.Combo47.Value
    
MsgBox getnm

Many thanks in advance

Dan
 

Gasman

Enthusiastic Amateur
Local time
Today, 05:56
Joined
Sep 21, 2011
Messages
14,231
Are you using Table Lookups for that field.?
 

DanSingleton

New member
Local time
Today, 05:56
Joined
Apr 2, 2020
Messages
10
Gasman

I believe yes (I am very rusty at all of this, been a while)

The Combo47 box is popuylated from this....


Code:
SELECT operators.ID, operators.f_name
FROM operators
WHERE (((operators.team)=[Forms]![team_setup]![Combo35]) AND ((operators.plant)=[Forms]![team_setup]![Combo39]))
ORDER BY operators.f_name;
 

DanSingleton

New member
Local time
Today, 05:56
Joined
Apr 2, 2020
Messages
10
Gasman thank you for taking some time to look at it. Ironically it was when pasting in this thread I saw where I was going wrong. I also had multiple columns within the combobox, and was not seeing all i needed.

Thank you anway
 

Rene vK

Member
Local time
Today, 06:56
Joined
Mar 3, 2013
Messages
123
Code:
getnm = Me.Combo47.Column(1)
 

Gasman

Enthusiastic Amateur
Local time
Today, 05:56
Joined
Sep 21, 2011
Messages
14,231
Hmm, OK. Table lookups look great when you first start with Access, but this is their biggest issue.
The best thing would be to remove the table lookup I believe.? However I do not think that is the problem, and you've now posted to say it is not. :)

Anyway, do not leave these as combo anything. After a few weeks it will be meaningless, give then meaningful names.
 

Users who are viewing this thread

Top Bottom