Re: Disable fields on Submit



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
>> >********
>

.



Relevant Pages

  • Re: Disable fields on Submit
    ... > first record), but, unless the first record was already the ... Requery will make the first record current ... > code control names. ... > For Each ctl In Me ...
    (microsoft.public.access.formscoding)
  • RE: Requery/refresh
    ... A Requery will always go back to the first record in the recordset, ... Also, if the control ... The subform subfrm_details has details of absence types ...
    (microsoft.public.access.modulesdaovba)
  • Re: Combo Box problem
    ... yes I'm using requery in the afterupdate event of the combo ... enable the user to add to the list of values in the combo control and ... form goes to the first record and doesn't stay with the current one. ... Rick Brandt, Microsoft Access MVP ...
    (microsoft.public.access.forms)
  • Re: requery & stay on record
    ... I had been working with the subform and it would go back to the first record. ... But i have a question regarding the requery. ... Control: MinPLT ...
    (microsoft.public.access.forms)
  • Re: Checking for 3 dates
    ... I just have to fix the requery problem. ... The three date fields do not have any Required in a control. ... at all the controls that have their Tag property set to "Required". ... Go to the Other tab of the property sheet, ...
    (microsoft.public.access.modulesdaovba)