Results 1 to 12 of 12
  1. #1
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Prevent Edits (A2K SP3)

    I have a form, frmCheckInLast.

    When the form is opened, it calls up the last record for review before extending a guest. If the
    guest is to be extended, the operator presses a

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Prevent Edits (A2K SP3)

    That is very strange. If Allow Edits is No, you shouldn't be able to select anything from a combo box. Are you sure there is no confusion between main form and subform, or something like that?

  3. #3
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Prevent Edits (A2K SP3)

    There is no subform. The Data Form properties are set as follows:

    Allow Filters: Yes
    Allow Edits No
    Allow Deletions: Yes
    Allow Additions: Yes
    Data Entry: No
    Recordset Type: Dynaset
    Record Locks: No Locks

    What about Locking the record and then unlocking it with the New Record button and then relocking after the record is saved.
    I'm not sure how to do that. Currently the New Record button fires a macro.
    GoToRecord Record = New
    GoToControl Control Name - PayCodeID
    Close Object Type= Macro
    ObjectNane= mcrNewRecordLast
    Save = Prompt

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Prevent Edits (A2K SP3)

    Normally, one would (un)lock a record by setting AllowEdits to True or False, but apparently, that is not sufficient in your case. As an additional measure, you could set the Locked property of the combo box to True or False (use the SetValue macro action.)

    BTW, if you like, you can post a stripped down version of your database:
    <UL><LI>Make a copy of the database and work with that.
    <LI>Remove all database objects (tables, queries, forms, reports, macros and modules) that are not relevant to the problem.
    <LI>In the remaining table(s), remove most records - leave only the minimum number necessary to demonstrate the problem.
    <LI>Remove or modify data of a confidential nature.
    <LI>Do a compact and repair (Tools/Database Utilities).
    <LI>Make a zip file containing the database; it should be below 100KB.
    <LI>Attach the zip file to a reply.[/list]That would enable us to inspect the form and see if we can find the cause of your problem.

  5. #5
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Prevent Edits (A2K SP3)

    As requested.

    Room numbers in the database are 112, 201, 202, 203 and 214

    Tom
    Attached Files Attached Files

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Prevent Edits (A2K SP3)

    Well, I can't say I understand it completely, but I found out what's happening. You've got code in the On Got Focus event of the PayCodeID combo box that modifies values on the form. I would have thought that this would cause an error message since Allow Edits = No, but apparently, it unlocks the form. You also have code in the On Got Focus event for the NumberOfDays text box, but in the copy you posted, this code has got disconnected from the control (the On Got Focus event in the Properties window is blank); after selecting Event Procedure, clicking in Number of Days also unlocked the form.

    Do you really need the code in On Got Focus?

  7. #7
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Prevent Edits (A2K SP3)

    The code in # of days is On Lost Focus as follows:

    Private Sub NumberofDays_LostFocus()
    Dim strMsg As String, strControl As String
    If Me![PayCodeID] = 5 And [NumberofDays] <> 3 Then
    strMsg = "Number of Days must be 3 for Business Pay Period."
    strControl = "PayCodeID"
    MsgBox (strMsg)
    DoCmd.GoToControl strControl
    End If
    End Sub

    I will have to dig back in the documentation to see if I can find out why both the After Update and On got Focus code was used in PayCode. It seems as it was added as a result of a problem encountered. I will check tomorrow and see if I can find the rationale or do some testing by deleting the On Got Focus and see if I can re-create the problem. This form was designed a long time ago.

    Tom

  8. #8
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Prevent Edits (A2K SP3)

    The reason that the PayCodeID field had both an After Update event and an On Got Focus event was to prevent the operator from changing the room rate say for a weekly rate and then realising that she had made a mistake. If she the clicks on the PayCodeID field and hits enter the rate does not change back to the correct rate. If, however, she uses the pull down menu and ckicks on the Weekly rate it then corrects itself.

    I think there is no problem in changing the On Lost Focus event to an After Update event on the # of Days field.

    Locking all records in the form properties does not appear to have any effect on the editing. I tried locking the 2 individual fields but somehow that unlocks the other fields on the forms. That is it prevents editing the two fields but allows you to edit the other fields.

    Any thoughts?

    Tom

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Prevent Edits (A2K SP3)

    Oops, sorry. You would have to set Locked to Yes and Enabled to No; the latter will prevent the On Got Focus event to occur.

  10. #10
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Prevent Edits (A2K SP3)

    Hans,

    Many thanks.

    In the field property of PayCodeID, I set Enabled to No and Locked to Yes. Then in the New Record Macro, I used a Set Value action and Set Enabled to True and Locked to False. On calling up another record, the field properties appear to revert to the original Enabled = No and Locked = Yes which is what I want to happen so there is no need to re-set to the original values. Do I understand this correctly?


    Thanks,

    Tom

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Prevent Edits (A2K SP3)

    If you re-open the form, the properties as set in design view will apply. If you move to another record without closing the form in between, the properties should stay as you last set them, unless other code intervenes.

  12. #12
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Prevent Edits (A2K SP3)

    Thanks.
    They can not move to another record without closing the form.

    Tom

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •