Hi folks,
A simple one? I'm trying to reference a ListView selection in a MsgBox but I can't seem to get it to work. I've tried:
If I remove the ListView section it works fine.Please Login or Register to view this content.
Any ideas?
SA
Hi folks,
A simple one? I'm trying to reference a ListView selection in a MsgBox but I can't seem to get it to work. I've tried:
If I remove the ListView section it works fine.Please Login or Register to view this content.
Any ideas?
SA
Last edited by SAsplin; 01-10-2013 at 11:57 AM.
Try replacing
withPlease Login or Register to view this content.
Please Login or Register to view this content.
If you like my contribution click the star icon!
OllieB - thanks for the reply. I did try that before but it returns a run time error (91):
Object variable or With block variable not set
SA
Are you running the statement from a routine within the form? If not you may need to add a reference to the form like in the example below
if you are running the statement from within a form, the reference is not needed (at most use "Me."). Are you (in that case) sure about the name of the ListView object, i.e. ListView1?Please Login or Register to view this content.
I've have tried changing the code to
andPlease Login or Register to view this content.
These both return the same run time error (91). The statement is being run from within a form and the ListView object is definitely called ListView1 - the vb editor picks it up as you enter the code.Please Login or Register to view this content.
I include the full code for the event below:
Please Login or Register to view this content.
is what Ollie B meant for you to use I believePlease Login or Register to view this content.
Josie
if at first you don't succeed try doing it the way your wife told you to
Thanks JosephP. I did try that variation too and it also returns the run time error.
can you post a file-that code works perfectly here
Maybe there is an action just before the message box is displayed that invalidates the SelectedItem property (like a refresh/reload or something)?
Unfortunately, my company's security measures won't let me upload any files. The code I posted is attached to a standard command button and the ListView object is version 6.0.
Under certain conditions you execute a refresh before displaying the message, hence there will no longer be a selecteditem. Save the value of SelectedItem at the beginning of your routine and use that variable in your message
I posted the full code for the button at post #5.
I removed the ListView.Refresh line before the MsgBox but still getting the run time error.
Can you check the code below
Please Login or Register to view this content.
That returns the run time error (91) on line
I promise you the object is called ListView1!!Please Login or Register to view this content.
Try removing ".Text", just for arguments sake
Same run time error. I'm beginning to wonder if I really need a MsgBox here at all!
does
work?Please Login or Register to view this content.
JosephP - yup. If I add that line of code I get the result 0. No run time error though!
Sorry - empty ListView. I get a value returned in relation to the number of entries in the ListView box.
Last edited by SAsplin; 01-10-2013 at 11:29 AM.
perhaps a brute force approach
Please Login or Register to view this content.
That's only gone and done it! JosephP you're a veritable genius. Many thanks - I was beginning to despair! I'm more than happy to add to your rep for the time and effort you've put in on this one.
Thanks again!
you're welcome :-)
thank you for the rep
Just out of curiosity, does this,
or this,Please Login or Register to view this content.
return anything.Please Login or Register to view this content.
If posting code please use code tags, see here.
Hi Norie,
.Key returns a blank value and .Index returns 1
SA
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks