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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select/De-Select Buttons fail to Call Subform

Status
Not open for further replies.

TravisT42

Technical User
Jan 7, 2008
7
US
Hello All,

I have a form frmDTRPrep with a subform frmDTRPick. On DTRPick there is a field Pkgd which is a checkbox. The idea is that users pick the boxes they want to add to a shipping request. Works fine as is, but for the times when there are too many boxes to just click on one by one, I want to add controls on the main form to check/uncheck all.

Here is what I have so far for the de-select all:
Code:
Private Sub Command10_Click()
Dim rs As DAO.Recordset
Set rs = Forms!frmDTRPrep!sfmDTRPick.Form.RecordsetClone
Do While Not rs.EOF
  rs.Edit
  rs!Pkgd = False
  rs.Update
  rs.MoveNext
Loop
Set rs = Nothing
End Sub
But every time I click the button I get the error that Access can't find the field "sfmDTRPick". Clearly, I'm not writing out the call for the subform correctly, but darned if I know what I'm doing wrong.

Ideally, I'd like the button to be able to select/de-select all, but having one less button is not as important to me as getting the thing to work correctly.
 
How are ya TravisT42 . . .

If the code is running in the mainform, try this:
Code:
[blue]Set rs = [sfmDTRPick].Form.RecordsetClone[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Hi Aceman,

Not too shabby apart from this fershlugginer control, thanks.

I tried the code and received the error that Access can't find the field '|'.
 
Why not simply an UPDATE query ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Yeah, okay, just go ahead and give me the simple, elegant solution, PHV. ;)

But, in case my future needs can't be met with such a straightforward answer, how *could* I make that code work? I can't imagine this will be the only time I need to reference a control on a subform.
 
TravisT42 said:
[blue]I have a form frmDTRPrep with a subform [purple]frm[/purple]DTRPick.[/blue]
TravisT42 said:
[blue]Set rs = Forms!frmDTRPrep![purple]sfm[/purple]DTRPick.Form.RecordsetClone[/blue]
. . . and the subform name is? . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Ah, good catch, AceMan. The subform name is sfmDTRPick.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top