Lock records against edits

M

mikeycan

Hello,

I have a form with several subforms that lists invoice information. Within
one of the subforms there is a check box that indicates if invoice is
complete. I am trying to lock the forms from update if the check box is
checked. I have searched through the Access Discussions groups and some VB
code. I tried to drop in my form names, but is does not work. It only works
on the subform with the check box, but not on any of the other related
subforms. What am I doing wrong?

Parent: [frmRA – Invoices]
Subforms : [frmRA - Invoice Attributes]
[frmRA - Invoice by Revenue Category]
[frmRA - Invoice Deferrals]
[frmRR - Order Review Details]

Code:
Private Sub Form_Current()
If Forms![frmRA - Invoices]![frmRA - Invoice Attributes]![InvoiceComplete] =
True Then
Me.AllowEdits = False
Me.AllowDeletions = False
Else
Me.AllowEdits = True
Me.AllowDeletions = True
End If
End Sub
 
P

Pat Hartman

"Me" refers to the form or report in which the code is running. If you want
to refer to properties of other forms - they must be open and you must use
the full reference name - Forms!......
 
M

mikeycan

Hello Pat,

Thank you for the reply. Does it matter that I have this code on the On
Current property for each subform? Shouldn't this let access know that the ME
referrs tot he currently opened subform? Also I have previously attempted to
replace the "Me" with the full reference to the form and I get an error back
from VB that is cannot find the referenced form. I cut and pasted the form
name to make sure I didn't just misspell it.

Pat Hartman said:
"Me" refers to the form or report in which the code is running. If you want
to refer to properties of other forms - they must be open and you must use
the full reference name - Forms!......

mikeycan said:
Hello,

I have a form with several subforms that lists invoice information.
Within
one of the subforms there is a check box that indicates if invoice is
complete. I am trying to lock the forms from update if the check box is
checked. I have searched through the Access Discussions groups and some
VB
code. I tried to drop in my form names, but is does not work. It only
works
on the subform with the check box, but not on any of the other related
subforms. What am I doing wrong?

Parent: [frmRA - Invoices]
Subforms : [frmRA - Invoice Attributes]
[frmRA - Invoice by Revenue Category]
[frmRA - Invoice Deferrals]
[frmRR - Order Review Details]

Code:
Private Sub Form_Current()
If Forms![frmRA - Invoices]![frmRA - Invoice Attributes]![InvoiceComplete]
=
True Then
Me.AllowEdits = False
Me.AllowDeletions = False
Else
Me.AllowEdits = True
Me.AllowDeletions = True
End If
End Sub
 
P

Pat Hartman

When I read your first post it sounded like you were trying to control
everything from one place. If the code runs within the form whose
properties you are trying to set, then Me. is correct. Using the full form
reference also works but you need to account for the fact that some forms
are actually subforms. Forms!mainform!subformname.Form.someproperty

Try this to reference a form field in subform which is open on this form or
a different form.

Forms![frmRA - Invoices]![frmRA - Invoice Attributes].Form![InvoiceComplete]

mikeycan said:
Hello Pat,

Thank you for the reply. Does it matter that I have this code on the On
Current property for each subform? Shouldn't this let access know that the
ME
referrs tot he currently opened subform? Also I have previously attempted
to
replace the "Me" with the full reference to the form and I get an error
back
from VB that is cannot find the referenced form. I cut and pasted the form
name to make sure I didn't just misspell it.

Pat Hartman said:
"Me" refers to the form or report in which the code is running. If you
want
to refer to properties of other forms - they must be open and you must
use
the full reference name - Forms!......

mikeycan said:
Hello,

I have a form with several subforms that lists invoice information.
Within
one of the subforms there is a check box that indicates if invoice is
complete. I am trying to lock the forms from update if the check box
is
checked. I have searched through the Access Discussions groups and
some
VB
code. I tried to drop in my form names, but is does not work. It only
works
on the subform with the check box, but not on any of the other related
subforms. What am I doing wrong?

Parent: [frmRA - Invoices]
Subforms : [frmRA - Invoice Attributes]
[frmRA - Invoice by Revenue Category]
[frmRA - Invoice Deferrals]
[frmRR - Order Review Details]

Code:
Private Sub Form_Current()
If Forms![frmRA - Invoices]![frmRA - Invoice
Attributes]![InvoiceComplete]
=
True Then
Me.AllowEdits = False
Me.AllowDeletions = False
Else
Me.AllowEdits = True
Me.AllowDeletions = True
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top