TSCAmerica.com
TSCAmerica.com

Reputation: 5377

Ms Access List Box - Pass parameter on Double click to a new form

I have a listbox in Microsoft Access 2010

enter image description here

I am trying to pass all parameters to a new form(frmpopUpPatientInfo) on double click of a record, example when I click on Patient:21, it should pass 21, Clinton, bill to new form. What i tried is below where lstEvents is listbox name, frmCalendar is the parent form

Private Sub lstEvents_DblClick(Cancel As Integer)
    DoCmd.OpenForm "frmpopUpPatientInfo"

    MsgBox Me.Parent.frmCalendar.lstEvents.Column(1), vbInformation, "Test"

End Sub

The Error i am getting is

enter image description here

Upvotes: 0

Views: 673

Answers (2)

Alex Hedley
Alex Hedley

Reputation: 786

Try

Forms!frmCalendar!lstEvents.Column(1)

https://www.599cd.com/tips/access/forms-formname-field-notation/

Upvotes: 1

Wayne G. Dunn
Wayne G. Dunn

Reputation: 4312

If you are trying to pass to a NEW form that was opened, you should not be using the 'Parent....' reference.

Below are two methods of passing data to a form.

' Pass arguments when the form is opened
DoCmd.OpenForm "frmpopUpPatientInfo", acNormal, , , , , Format(Now(), "DD-MMM-YYYY")
' Or reference a control as follows:
Forms!frmpopUpPatientInfo.myTargetField= Format(Now(), "DD-MMM-YYYY")

Upvotes: 1

Related Questions