ComboBox VBA (1 Viewer)

coleman01

New member
Local time
Today, 21:16
Joined
Feb 28, 2005
Messages
8
Hi, I have a combobox with two columns - e.g.

1001 "Roger Spencer"

When i use:

userNom = comboNom.column(2),

The debugger returns "null"

I thought that the index may have started at 0, so i tried combonom.column(1) and that still returned null.

Any ideas on how to return the second column value of a combobox?
 

KenHigg

Registered User
Local time
Today, 16:16
Joined
Jun 9, 2004
Messages
13,327
I didn't even know you could get what was in the second (or unbound), col, but even so, wouldn't you need something like:

userNom = myfrmName!comboNom.column(2)

???
Ken
 

WayneRyan

AWF VIP
Local time
Today, 21:16
Joined
Nov 19, 2002
Messages
7,122
Coleman,

The index does start at 0, and your syntax looks OK.

SomeThing = Me.YourCombo.Column(1)

Wayne
 

coleman01

New member
Local time
Today, 21:16
Joined
Feb 28, 2005
Messages
8
Still get error

all i get is

Run Time error 94 --> invalid use of null
 

GRM-kenyette

Miss Kenyette
Local time
Today, 16:16
Joined
Mar 10, 2005
Messages
15
I Had That Problem , You have To Go To The Properties Of The Combobox And Set The Col Count To 2, Don't Mess With The Code
 
Last edited:

coleman01

New member
Local time
Today, 21:16
Joined
Feb 28, 2005
Messages
8
Still got the error

It's set to 2 but I still get the error?

Any ideas anyone?
 

RoyVidar

Registered User.
Local time
Today, 22:16
Joined
Sep 25, 2000
Messages
805
Is there a selection in the combo when the error occurs?

The problem probably occurs because of that, and you get an error because you're trying to assign a Null to a string variable, which isn't allowed.

You might for instance test whether there is a selection made prior to this, perhaps:

if me!cboMyCombo.listindex<>-1 then
strSomeString=me!cboMyCombo.column(1)
end if
 

coleman01

New member
Local time
Today, 21:16
Joined
Feb 28, 2005
Messages
8
Cheers

How odd.

I put the if statement in and it still didn't work. After I made the combobox have the focus it worked.

Strange. Thank you very much for that. I really appreciate it.
 

Users who are viewing this thread

Top Bottom