Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Allowedits property is still allowing edits

Status
Not open for further replies.

Durkin

Programmer
Nov 6, 2000
304
GB
I have a transactions (ie. financial transactions) form where the allowedits property of the form is set to false if the status of the transaction is 'Posted'. The property is being set fine, if I go to the debug screen and type forms!frmTransactions.allowedits it returns false. However, on the screen I can change whatever I like. All the controls are bound and I have code in both the load and current events of the form to set this property. Also, if I make a change and then press Esc to undo it the form locks up like it's supposed to. Any ideas? Durkin
 
Once you allowedits *by doing your postings* allowedits is now true even though you have it set to false in the form properties. So you need to put some code behind the posting.

In otherwords I would place in the form oncurrent event Me.allowedits = 0 now you have the form locked. How do you allowedits for the posting? Do you have a command button to allowedits? You might consider some sort of flag to check it the form is posted and based on the results of that flag allowedits or not.

blnOK as Boolean

blnOK = 0

now if we got a posting then blnOK = -1

so something like this might work.

If blnOK = -1 then
Me.Allowedits = 0
else
me.Allowedits = -1
end if

you get the idea?

Good Luck...

Life's a journey enjoy the ride...

jazzz
 
Hi jazzz, thanks for your response. I have code in the oncurrent event which sets this property to false if the 'posted' field is true and sets it to true if it's not. The problem is that, even though this code seems to be working - if I check the allowedits property it is always set properly - I can still edit the record even when I shouldn't be able. Durkin
 
then evidently the code is not correct. I control edits on all my forms without incidence.

How I control my controls is with the tag property for each control for example I created a function which I make public so that I can call it in all my forms. In the tag property I place NoEdit for text boxes and chkNoEdit for check boxes. I then gray out the labels of the check boxes to give the effect of being disabled.

Public Function NoEditOff(frm As Form)

On Error GoTo Err_PurNoEditPropertiesoff

Dim C As Control
Dim lngWhite As Long
Dim lngblack As Long

lngWhite = RGB(255, 255, 255)
lngblack = RGB(0, 0, 0)

For Each C In frm.Controls
If C.Tag = "NoEdit" Then
With C
.Enabled = -1
.Locked = 0
.BackColor = lngWhite
End With
End If

If C.Tag = "chknoedit" Then
With C
.Enabled = -1
.Locked = 0
End With
End If

If C.Tag = "lblnoedit" Then
With C
.ForeColor = lngblack
End With
End If

Next


Exit_PurNoEditPropertiesoff:
Exit Function

Err_PurNoEditPropertiesoff:
'* If we run into an error display our form and create an
'* errorlog.txt file. If no error's are detected exit the
'* program.

Select Case Err.Number
'* Handle errors here.
Case Else
Call ShowError("modmessages", "NoEditOff", Err.Number, _
Err.Description)
End Select

Resume Exit_PurNoEditPropertiesoff

End Function

here I use it for both text boxes and check boxes it would be called by using NoEditOFF ME now naturally you need to create a similiar Function to do just the opposite. Now my error handle won't work so place a generic one where the Showerror line is.
Life's a journey enjoy the ride...

jazzz
 
One final thought after re-reading your post. Before your code oncurrent place me.AllowEdits = 0 now on the AfterUpdate Event on your form properties add
me.AllowEdits = 0 that should do it. Life's a journey enjoy the ride...

jazzz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top