RE: locking subform
- From: "Brian" <Brian@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 4 Aug 2005 09:42:02 -0700
Access does not recognize "sbfrmItems" as a valid object (i.e. subform) on
your form and therefore thinks it is an undeclared variable. Check & recheck
the spelling. Try this:
Go to design view of your form.
Right-click on the upper right-hand corner of the subform.
Click Properties.
Click the "Other" tab.
Copy the subform name & paste it here:
I just want to make sure it is exactly the same. I am not aware of any
alternative way to refer to the subform. I just posted this question in the
same forum. Give it a couple of hours, and search this forum for "Subform
reference". If the spelling is indeed exact, maybe someone else knows some
trick that is needed to get the correct reference. I am using Access 2003,
and perhaps something was different in Access 2000.
"Katayon" wrote:
> Ok. I inserted and I compiled, and I received the following error:
>
> "Variable not defined" and it was highlighting "sbfrmItems" from the sub
> click.
>
> I am using Microsoft Access 2000 (9.0.2720)
>
>
> "Brian" wrote:
>
> > Make a backup copy of your form first, and then replace your click sub with
> > this. After inserting it (but with the module still open, click Debug ->
> > Compile. This forces it to attempt to compile and will pinpoint any compile
> > errors immediately. See if it generates any errors, and if so, where. If
> > there are no errors, try running it. Also, which version of Access are you
> > using?
> >
> > Private Sub SaveRecord_Click()
> > On Error GoTo Err_SaveRecord_Click
> > DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
> > CMID.Locked = True
> > ArchiveDate.Locked = True
> > SCR.Locked = True
> > Build.Locked = True
> > CMID.Locked = True
> > ComponentName.Locked = True
> > Comments.Locked = True
> > Provider.Locked = True
> > sbfrmItems.Locked = True
> >
> > Exit_SaveRecord_Click:
> > Exit Sub
> >
> > Err_SaveRecord_Click:
> > MsgBox Err.Description
> > Resume Exit_SaveRecord_Click
> > End Sub
> >
> >
> > "Katayon" wrote:
> >
> > > 1. yes, the name is sbfrmItems
> > >
> > > 2.
> > >
> > > Private Sub SaveRecord_Click()
> > > On Error GoTo Err_SaveRecord_Click
> > >
> > > DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
> > >
> > > Me!CMID.Locked = True
> > > Me!ArchiveDate.Locked = True
> > > Me!SCR.Locked = True
> > > Me!Build.Locked = True
> > > Me!CMID.Locked = True
> > > Me!ComponentName.Locked = True
> > > Me!Comments.Locked = True
> > > Me!Provider.Locked = True
> > >
> > > sbfrmItems.Locked = True
> > >
> > > Exit_SaveRecord_Click:
> > > Exit Sub
> > >
> > > Err_SaveRecord_Click:
> > > MsgBox Err.Description
> > > Resume Exit_SaveRecord_Click
> > >
> > > End Sub
> > >
> > >
> > >
> > > "Brian" wrote:
> > >
> > > > Two things:
> > > >
> > > > 1. What is the name of your subform? Is it sbfrmItems?
> > > > 2. Post the full sub VBA code again with this reference in it.
> > > >
> > > > "Katayon" wrote:
> > > >
> > > > > Thanks Brian. But now I am getting an error:
> > > > >
> > > > > Compile error: variable not defined
> > > > >
> > > > > any thoughts on that?
> > > > >
> > > > > thanks again,
> > > > > katayon
> > > > >
> > > > >
> > > > > "Brian" wrote:
> > > > >
> > > > > > Refer to the subform just by its name (just like your controls.
> > > > > >
> > > > > > sbfrmItems.Locked = True
> > > > > >
> > > > > > "Katayon" wrote:
> > > > > >
> > > > > > > Hi,
> > > > > > >
> > > > > > > I have searched through all previous messages, and can not find this
> > > > > > > specific answer. I think its pretty simple, but I just can't get it right.
> > > > > > >
> > > > > > > I have a form, and the form has a command button to "Save" (i.e. Lock all
> > > > > > > fields), and here is the code for it.
> > > > > > >
> > > > > > > ____________________________________
> > > > > > > Private Sub SaveRecord_Click()
> > > > > > > On Error GoTo Err_SaveRecord_Click
> > > > > > >
> > > > > > > DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
> > > > > > >
> > > > > > > Me!CMID.Locked = True
> > > > > > > Me!ArchiveDate.Locked = True
> > > > > > > Me!SCR.Locked = True
> > > > > > > Me!Build.Locked = True
> > > > > > > Me!CMID.Locked = True
> > > > > > > Me!ComponentName.Locked = True
> > > > > > > Me!Comments.Locked = True
> > > > > > > Me!Provider.Locked = True
> > > > > > >
> > > > > > > Exit_SaveRecord_Click:
> > > > > > > Exit Sub
> > > > > > >
> > > > > > > Err_SaveRecord_Click:
> > > > > > > MsgBox Err.Description
> > > > > > > Resume Exit_SaveRecord_Click
> > > > > > >
> > > > > > > End Sub
> > > > > > > ___________________________
> > > > > > >
> > > > > > > This works fine. But I can not figure out the code to lock the subfrom
> > > > > > > (sbfrmItems) in the same manner as well.
> > > > > > >
> > > > > > > I have tried things like: Me!sbfrmItems.Form.Locked = True
> > > > > > > and I get an error saying "...can't find the field 'sbfrmItems' referred to
> > > > > > > in your expression."
> > > > > > >
> > > > > > > Can someone please tell me what is the proper code for locking a subform,
> > > > > > > persistant to the way I am locking individual fields (i.e. textboxes,
> > > > > > > drop-downs...).
> > > > > > >
> > > > > > > Thanks in advance!
> > > > > > >
.
- Follow-Ups:
- RE: locking subform
- From: Katayon
- RE: locking subform
- References:
- locking subform
- From: Katayon
- RE: locking subform
- From: Brian
- RE: locking subform
- From: Katayon
- RE: locking subform
- From: Brian
- RE: locking subform
- From: Katayon
- RE: locking subform
- From: Brian
- RE: locking subform
- From: Katayon
- locking subform
- Prev by Date: Subform reference
- Next by Date: Input Form
- Previous by thread: RE: locking subform
- Next by thread: RE: locking subform
- Index(es):
Loading