Can't stop user from editing form

Tech-Archive recommends: Fix windows errors by optimizing your registry



I’m having a problem getting the AllowEdits property to work.

Here is the issue. I have a form - frmOrders . The forms Form_Current event
has the following line of code:

AllowEdits = False

This works fine and when the user tries to edit a field on the form he is
unable to. However, if the user clicks in or enters the control cboLookup1
and then navigates to any other control on the form he is able to edit the
form. In other words the form has now reset itself to allow edits in any and
all fields.

There are 4 control properties named cboLookup1, cboLookup2, cboLookup3, and
cboLookup4. If the user clicks or enters any one of these fields and then
exits to another field the form then allows edits.

There is code associated with these fields.

Here is the code that is in the LostFocus event on the combo box control
cboLookUp1.
[code]
Private Sub cboLookUp1_LostFocus()

Dim varExtCost As Variant
Dim varItem As Variant
Dim varCost As Variant

varItem = DLookup("descript", "tblItems", "[ItemNo]=cbolookup1")
If (Not IsNull(cboLookUp1)) Then Me![txtItem1] = varItem
varCost = DLookup("cost", "tblItems", "[ItemNo]=cbolookup1")
If (Not IsNull(cboLookUp1)) Then Me![txtCost1] = varCost


varExtCost = Nz(txtQty1, 0) * Nz(txtCost1, 0)
If (Not IsNull(txtQty1)) Then Me![txtExt1] = varExtCost

End Sub
[/code]

The other 3 controls have the same code.

I know it has something to do with this code because I’ve removed the code
and the form will stay read only if this code does not fire. Yes, I’ve tried
putting [b]AllowEdits = False[/b] statements in the LostFocus events and that
doesn’t help.

If anyone can offer any help it would be greatly appreciated.

Thanks for your time.

.



Relevant Pages

  • Re: why can I still edit data when I set the "allowedits" property to
    ... If there is an edit in progress when you set the form's AllowEdits property ... you need a related table to hold the multiple ... The form properties have no apparent control. ...
    (microsoft.public.access.forms)
  • Re: Cant stop user from editing form
    ... when the user enters the combo box, set the form's AllowEdits to True ... This works fine and when the user tries to edit a field on the form he is ... if the user clicks in or enters the control cboLookup1 ... Dim varExtCost As Variant ...
    (microsoft.public.access.formscoding)
  • Re: I want to get rid of a beep
    ... If I press enter when the edit box has focus, ... MyEditBox::MyEditBox(CWnd *parent, UINT nID) ... You cannot possibly know the dimensions of an edit control so ... MyEditBox::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) ...
    (microsoft.public.vc.mfc)
  • Re: how to stop last edit date changing when record just viewed or copied
    ... (All this applies to subform just the same as main forms.) ... ruling out Dirty or BeforeUpdate??). ... of the user and then sets the visible property of Edit, Delete, Add, ... its contents to another control. ...
    (microsoft.public.access.formscoding)
  • Re: programmatically initialize properties of dialog controls
    ... for font I couldn't manage without specifying font name. ... concatenating in edit box - it just occurred to me that all the same I ... >>First make sure that you have attached a variable to any control that you ... > or check boxes, you can create value variables which you initialize before ...
    (microsoft.public.vc.mfc)