Reputation: 9
Im new to Access and need some help. D: So I have a form in datasheet view which displays basic information of all the records from a query. By pressing a text field at the end of each record it opens another form in edit mode with the details of that specific record.
But after it opens I want to disable or hide some fields and controls including a button which clears all the fields in the form so that users can't press it accidentally and erase all Information in the form. I've tried this code:
Private Sub Text23_Click()
DoCmd.OpenForm "FrmEntregas", acNormal, "", "[EntregasID]=" & Nz(CodeContextObject.EntregasID, 0), acEdit, acDialog
'Forms("FrmEntregas").btnReiniciar.Visible = False
'Forms!FrmEntregas!btnReiniciar.Visible = False
'Forms("FrmEntregas").Form.Controls(btnReiniciar).Visible = False
End Sub
The first line works great, the problem comes when refering to the form's button. I've tried refering to the button in three different ways but none of them work. It displays this message:
"Runtime Error 2450: Microsoft Access cannot find the referenced form 'FrmEntregas'."
If someone could point me in the right direction I'd be more than thankful!
Upvotes: 0
Views: 238
Reputation: 6336
Don't open in Dialog mode, the code after DoCmd works only when the form is closed. Change the Modal
property of the form to Yes
instead.
Private Sub Text23_Click()
DoCmd.OpenForm "FrmEntregas", acNormal, "", "[EntregasID]=" & Nz(CodeContextObject.EntregasID, 0), acEdit
Forms("FrmEntregas").btnReiniciar.Visible = False
End Sub
Upvotes: 1