Re: Disable fields on Submit
- From: Marshall Barton <marshbarton@xxxxxxxxxx>
- Date: Sat, 11 Jun 2005 09:28:08 -0500
Sure, bounce away ;-)
Well, yes, a Requery will run the Current event (on the
first record), but, unless the first record was already the
current record, Requery will make the first record current
and the locked procedure should be executed. I don't think
it's worth worrying about, but if it is an unacceptble
performance hit, you could check to see if one of the
controls is already locked and skip the loop.
As for the Tag property, I would rather use InStr than hard
code control names.
For Each ctl In Me
If InStr(ctl.Tag, "LOCK") > 0 Then ctl.Locked = True
Next ctl
Another technique that I have used occasionally is to add a
prefix to the control names (e.g. LOCKcboProduct) so the
loop would look like:
For Each ctl In Me
If Left(ctl.Name, 4) = "LOCK" Then ctl.Locked = True
Next ctl
--
Marsh
MVP [MS Access]
Connie wrote:
>If you don't mind can I bounce a couple of questions off you?
>1) If you use the form's Current event to check if record has been submitted
>... aren't you possibly checking it more than needed .. for ex if they are
>using requery in the form ... the OnCurrent would trigger each time for the
>same record, correct?
>
>2) The loop with the Tag property is a great idea, however I use the Tag for
>other things in my code & you can't use it for multiple things, right? Or
>maybe you could using the Instr / Mid functions ... but I would think that
>could get very confusing?
>
>
>"Marshall Barton" wrote
>> Excellent ideas, Connie.
>>
>> If I may add some additional thoughts, use the form's
>> Current event to check if a record has been submitted.
>>
>> Instead of checking for the names of specific controls to
>> lock/enable, set those control's Tag property to an
>> indicator string such as LOCK. Then the code loop would
>> look like:
>> For Each ctl In Me
>> If ctl.Tag = "LOCK" Then ctl.Locked = True
>> Next ctl
>>
>> Another thought, if the Submitted field were a Date type
>> field, then the test for submitted records would only be
>> slightly differentL
>> If Not IsNull(Me.Submitted) Then
>> . . .
>> but you would gain the additional benefit of recording the
>> date that the record was submitted, which could also be used
>> for further analysis.
>>
>>
>> Connie wrote:
>> >Hopefully your users are accessing the data via forms, so you can control
>> >this by your form. You might need to add a new field in the table that
>> >indicates this record has been submitted (for this example I'm using a
>> >yes/no field). You'll also need to add this field to the form & make
>it's
>> >visible property to No. When a user clicks the submit button you'll need
>to
>> >write code that will check the yes/no field (see below for example).
>> >
>> >Now what I generally do is create 2 subroutines ... 1 called DisableCtls
>> >(the code I previously sent) & 1 called EnableCtls .. copy same code as
>> >DisableCtls only change the False to True & the True to False. Then in
>the
>> >submit button's OnClick you would call the disable/lock code.
>> >
>> >If you have already put the previous code in the OnClick of the submit
>> >button, get rid of it & create the 2 subroutines above. Then put the
>> >following in the OnClick of the submit button.
>> >
>> >Note: if you named the control (of the new field) something else, just
>> >replace chkSubmit with the name you're using
>> >********
>> >Me!chkSubmit=True (if you are using a yes/no field)
>> >Call DisableCtls
>> >********
>> >
>> >Then if a user selects a record on this form that has already been
>submitted
>> >you'll need to run the enable/unlock code. If you have a combo box that
>a
>> >user selects existing records .. put this code in the AfterUpdate event
>> >(after the code that changes the form to the record they just selected).
>> >
>> >********
>> >If Me!chkSubmit=True then
>> > Call DisableCtls
>> >Else
>> > Call EnableCtls
>> >End If
>> >********
>
.
- Follow-Ups:
- Re: Disable fields on Submit
- From: Connie
- Re: Disable fields on Submit
- References:
- Disable fields on Submit
- From: Kayleen Huggart via AccessMonster.com
- Re: Disable fields on Submit
- From: Kayleen Huggart via AccessMonster.com
- Re: Disable fields on Submit
- From: Connie
- Re: Disable fields on Submit
- From: Marshall Barton
- Re: Disable fields on Submit
- From: Connie
- Disable fields on Submit
- Prev by Date: Re: Macro question
- Next by Date: List box behaviour Rli
- Previous by thread: Re: Disable fields on Submit
- Next by thread: Re: Disable fields on Submit
- Index(es):
Relevant Pages
|