Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass value from ListView to Pop-up Form

Status
Not open for further replies.

cuetzpalin

Programmer
Jun 5, 2002
99
US
Hello,

I have a Parent Form with a ListView that lists multiple records. I figured out how to capture the Index of the record that's double clicked, but how do I get to pass to a pop-up form?

Here's my code:

Private Sub lvxCA_Data_List_DblClick()

Dim lvxObj As ListView
Set lvxObj = lvxCA_Data_List.Object

With lvxObj
iOCISeq = .SelectedItem
End With

stDocName = "frmTest"
DoCmd.OpenForm stDocName, acNormal, , , , , iOCISeq


End Sub


Please help! Also, how do ensure that the pop-up form stays modal and basically locks the user from going back to the parent unless they close the pop-up form?

The pop-up form is meant to be a data input form, basically displays a more detailed view of the record selected from the ListView.

Thanks!
 
Personally if I am passing variables between forms (especially pop up forms) I just use a global variable. So in a standard module:

public iOCISeq as variant ( or some other var type)

open the form as dialog (acdialog), I think its the fifth parameter of docmd.openform.

Since the variable is global it can be used anywhere in the application.
 
That's helpful and makes sense. Thank you. However, what code needs to go into the pop-up form?

I have this in the form_load of the pop-up form to test if the value is being passed:

Private Sub Form_Load()
MsgBox iOCISeq, vbOKOnly, "Test"
End Sub

The value is "empty"

In the main form, in the General Declarations, I placed the global variable as:


Public iOCISeq As Variant

Why isn't it passing the value?

Oh and here's how I call the form:

stDocName = "frmMemberDetail"
stLinkCriteria = iOCISeq

DoCmd.OpenForm stDocName, , , , , acDialog, stLinkCriteria


Thanks again!
 
I figured it out!!

I created a standard module (duh I know u mentioned that) and it worked!

I thought that you meant put the declaration in the main form that contains the listview control.

Thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top