user3752718
user3752718

Reputation: 105

How to get element value of selected row in a subform

I have a Sub Form in MS Access as below :

Screen Shot

Is there any way to get the string value of the selected row when the user click on the row ?

I have tried using the ReportKey as follow :

SELECT MyRowName From TAB_MySubFormName WHERE TAB_MySubFormName.ReportKey=" & ReportKey

but the result of the ReportKey is always 1 which I guess it's the first element even thought I have clicked on the last element in the table

Upvotes: 1

Views: 2572

Answers (2)

user3752718
user3752718

Reputation: 105

I end up finding my error

I had to precise the SUB_Form.Form.ReportKey no need to precise the sub form name just simply add SUB_Form.Form.ReportKey , which means I had to do this :

SELECT MyRowName From TAB_MySubFormName WHERE TAB_MySubFormName.ReportKey=" & SUB_Form.Form.ReportKey

Upvotes: 1

mdialogo
mdialogo

Reputation: 473

Try this code in your main form:

MsgBox Nz(Me.YourSubform.Form!SomeField)

Upvotes: 0

Related Questions