linking to another form using a listbox

  • Thread starter krzysztof via AccessMonster.com
  • Start date
K

krzysztof via AccessMonster.com

Good Day!

I have a form that has a list box with multiple columns, and obviously,
multiple rows. i want to have the user double click a row, and open a form
that corresponds with the item selected. now, the double -click operation is
fine, and my form is fine, yet i keep getting error messages when i try to do
the operation. i am probably not identifying the right column, since that is
the value i want to pass.

my code is this:
Dim stFrmName As String
Dim stLinkCriteria As String

stFrmName = "frm_TempWO"
stLinkCriteria = "[TempWorkOrdID]=" & "'" & Me.UAList.Column(1) & "'"

DoCmd.OpenForm stFrmName, acNormal, , stLinkCriteria, , acWindowNormal

very much TIA

~k
 
J

Jeff Boyce

You are using Column(1) to pass an ID value. If your listbox is set up in a
normal fashion, the ID field is the first column in the source.

For geekly reasons, the .Column() property is zero-based. That means that
your first column/field in your source is referred to as .Column(0), not
..Column(1). Go figure!

Did that help?

--
Regards

Jeff Boyce
Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Microsoft Registered Partner
https://partner.microsoft.com/
 
G

Guest

k-

You didn't say what the error was, but I'll take a shot.

Listbox columns are zero-relative. The first column would be .Column(0).
That said, it appears that you are looking for a numeric value to do the
link, but you are trying to link using a string. Try this:

stLinkCriteria = "[TempWorkOrdID]=" & CLng(Me.UAList.Column(1))

HTH,
Bruce
 
K

krzysztof via AccessMonster.com

THANKS! i am not that clear headed on saturday mornings!!

makes sense about the zero, though.

Jeff said:
You are using Column(1) to pass an ID value. If your listbox is set up in a
normal fashion, the ID field is the first column in the source.

For geekly reasons, the .Column() property is zero-based. That means that
your first column/field in your source is referred to as .Column(0), not
.Column(1). Go figure!

Did that help?
Good Day!
[quoted text clipped - 17 lines]
 
K

krzysztof via AccessMonster.com

Now I am getting am message "Undefined function 'Me.UAList.Column(0)' in
experssion"

I also tried it with coverting it with a number as well...

any thoughts?
THANKS! i am not that clear headed on saturday mornings!!

makes sense about the zero, though.
You are using Column(1) to pass an ID value. If your listbox is set up in a
normal fashion, the ID field is the first column in the source.
[quoted text clipped - 10 lines]
 
G

Guest

Set a break point in your code, then step through one line at a time until it
fails. Send us a snippet of the code that includes the line that causes the
error.
Bruce

krzysztof via AccessMonster.com said:
Now I am getting am message "Undefined function 'Me.UAList.Column(0)' in
experssion"

I also tried it with coverting it with a number as well...

any thoughts?
THANKS! i am not that clear headed on saturday mornings!!

makes sense about the zero, though.
You are using Column(1) to pass an ID value. If your listbox is set up in a
normal fashion, the ID field is the first column in the source.
[quoted text clipped - 10 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top