Is a global variable the fix here?
-
- Lounger
- Posts: 47
- Joined: 26 Jan 2010, 01:05
Is a global variable the fix here?
When I have a user pick an item from a listbox, I'd like them to be able to double-click on the item and have a form pop up that will show the memo field for the record selected...I've got multiple list boxes that I'd like to be able to apply this to (in any list box that displays records from a particular table, I would like the user to be able to double click and the form with a text box pop up and show the user all the comments). How do I program the text box to look at the item selected in the list box, regardless of the list box that called the form?
-
- Administrator
- Posts: 78534
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Is a global variable the fix here?
You can pass the value of the list box to the popup form in the OpenArgs argument of DoCmd.OpenForm, and inspect the value of the OpenArgs property in the On Open or On Load event of the popup form.
In the code that opens the popup form:
DoCmd.OpenForm FormName:="frmPopup", WindowMode:=acDialog, OpenArgs:=Me.lstList
In the On Open or On Load event of the popup form:
If Not IsNull(Me.OpenArgs) Then
...
End If
See OpenForm method and OpenArgs property.
In the code that opens the popup form:
DoCmd.OpenForm FormName:="frmPopup", WindowMode:=acDialog, OpenArgs:=Me.lstList
In the On Open or On Load event of the popup form:
If Not IsNull(Me.OpenArgs) Then
...
End If
See OpenForm method and OpenArgs property.
Best wishes,
Hans
Hans
-
- Lounger
- Posts: 47
- Joined: 26 Jan 2010, 01:05
Re: Is a global variable the fix here?
Awesome...thanks!
-
- Lounger
- Posts: 47
- Joined: 26 Jan 2010, 01:05
Re: Is a global variable the fix here?
This works perfect, for one form... when I try to apply it to any other listbox controls, I double-click and get the error "An expression you entered is the wrong data type for one of the arguments". When checking what the openargs argument is, it reads 'Null'. Screenshot attached :)
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78534
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Is a global variable the fix here?
Null shouldn´t be a problem here, but try
..., OpenArgs:=CStr(Me.lstOne)
..., OpenArgs:=CStr(Me.lstOne)
Best wishes,
Hans
Hans
-
- Lounger
- Posts: 47
- Joined: 26 Jan 2010, 01:05
Re: Is a global variable the fix here?
Hm... well, I put a text box on the form to =lstone, as I select an item, the text box remains blank... does that mean the listbox is corrrupted?
-
- Administrator
- Posts: 78534
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Is a global variable the fix here?
Is that on the first form or on the comments form?
Best wishes,
Hans
Hans
-
- Lounger
- Posts: 47
- Joined: 26 Jan 2010, 01:05
Re: Is a global variable the fix here?
The first form.
-
- Administrator
- Posts: 78534
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Is a global variable the fix here?
In that case, the text box should display the value of the list box (which is not necessarily the displayed value - that depends on the column settings).
Best wishes,
Hans
Hans
-
- Lounger
- Posts: 47
- Joined: 26 Jan 2010, 01:05
Re: Is a global variable the fix here?
Right...I know that, but it's not working - any ideas other than form corruption?
-
- Administrator
- Posts: 78534
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Is a global variable the fix here?
I'm afraid not, I'd have to see (a stripped down and zipped) copy of the database.
Best wishes,
Hans
Hans
-
- Lounger
- Posts: 47
- Joined: 26 Jan 2010, 01:05
Re: Is a global variable the fix here?
Attached :)
Side note - what are the upload restrictions here in the new lounge? I know they (used to be) 100kb.
Side note - what are the upload restrictions here in the new lounge? I know they (used to be) 100kb.
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78534
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Is a global variable the fix here?
Try
=[lstOne].[Column](0)
if you want to see the value (hidden) first column of the list box (the ID), or
=[lstOne].[Column](1)
if you want to see the value of the first displayed column (the Update_Name).
BTW, the maximum size for an attachment here is 256 KB.
=[lstOne].[Column](0)
if you want to see the value (hidden) first column of the list box (the ID), or
=[lstOne].[Column](1)
if you want to see the value of the first displayed column (the Update_Name).
BTW, the maximum size for an attachment here is 256 KB.
Best wishes,
Hans
Hans
-
- Lounger
- Posts: 47
- Joined: 26 Jan 2010, 01:05
Re: Is a global variable the fix here?
Using .column worked...I thought I'd tried it already, perhaps my it was all in the execution though. Thanks :)