Avatar of dsg138
dsg138
 asked on

SQL statment in subform doesn't work when running from Parent form

Experts, here is a quick SQL Statement syntax question.

I have a subform called frmResponses.

I have a button with an OnClick event that runs the following SQL statment.
sSQL = "DELETE * FROM QSTNRT_SELECTION_PROB WHERE [QSTNRT_SELECTION_PROB_PID] = Forms![frmResponses]![ProbSelPID]"

It works correctly when I run it directly from frmResponses.

frmResponses is a subfrom on frmTree2 (the parent from).

When I access it through the parent form, frmTree2, I get prompted for...
Forms![frmResponses]![ProbSelPID]
Access doesn't recognize it...

I've tried numerous things such as:
Forms![frmTree2]![frmResponses]![ProbSelPID]
Forms.[frmTree2].[frmResponses].[ProbSelPID]

Forms![FrmTree2]![ProbSelPID]

Any ideas?

Thanks in advance...  

-dsg
Microsoft AccessSQL

Avatar of undefined
Last Comment
dsg138

8/22/2022 - Mon
Jim Horn

>When I access it through the parent form
sSQL = "DELETE * FROM QSTNRT_SELECTION_PROB WHERE [QSTNRT_SELECTION_PROB_PID] = " & Me.frmResponsesSubformObjectName.Forms!ProbSelPID
dsg138

ASKER
Thanks for the quick reply Jim...
I now get Method or Data Member not found.
dsg138

ASKER
Raised the pts some, if there are any other suggestions...  Thanks!
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
dsg138

ASKER
I'm still having some syntax issues with is.

The subform I'm refering to is a continuous subform and the button appears next to each record.

Do I really need to identify the parent form, being that it's all on the same line of the subform?

If anyone has some ideas, I'd really appreciate it.

-dsg
ASKER CERTIFIED SOLUTION
dsg138

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.