I've had a working function that modified some command buttons on a form. The code read, in part:
The form is now a subform, and I've not been able to get similar code to work:
It fails at the line above Next i with an error regarding incorrect reference to a form/report.
Any help is immensely appreciated.
George
Code:
Set frm = Forms!frmmomsbabies
strSQL = "SELECT baby_id,baby FROM babies WHERE mom_id = " & mom & " ORDER BY baby"
Set rs = CurrentDb.OpenRecordset(strSQL)
For i = 1 To 5
strCMD = "cmdBaby" & Trim(str(i))
frm.Controls(strCMD).Visible = False
Next i
Code:
Dim frm As SubForm
Set frm = Forms!frmMomsBabies!ctlSubMothers
strSQL = "SELECT baby_id,baby FROM babies WHERE mom_id = " & mom & " ORDER BY baby"
Set rs = CurrentDb.OpenRecordset(strSQL)
For i = 1 To 5
strCMD = "cmdbaby" & Trim(Str(i))
frm.Controls(strCMD).Visible = False
Next i
Any help is immensely appreciated.
George