Alex
Alex

Reputation: 113

MS Access - Get the current query name of a subform

I have a classic form and a subform that obtain records from a query and i want to assign to a variable the name of that query used by the subform:

Dim qryVar as String
qryVar = Me.subForm1.Query.Name

this doesn't work of course..

Upvotes: 0

Views: 241

Answers (1)

Warcupine
Warcupine

Reputation: 4640

In the parent form's code

Sub Test()
    Dim qryVar as string
    qryVar = Me.Controls("SubForm1").Form.RecordSource
    debug.print qryVar
End Sub

In Module code to call the test

Sub TestFormCode()
     Frm_ParentFormObject.Test 'Change this to whatever your form's name is
End Sub

Upvotes: 2

Related Questions