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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Locking multiuser form 1

Status
Not open for further replies.

integritycare

Technical User
Mar 12, 2011
151
0
0
AU
Hello,
Many thanks for the replies I got for my previous post. It has solved that issue.

Just to ask this question,

On the invoice system our company uses, the system allows a user to open a previously generated invoice to add more data. It happened that 2 users opened the same invoice at the same time to add data. I noticed that both were able to add data but the issue of deleting another's data could happen.
Perhaps a message box with a warning?
Is it possible using some form of record locking that no data can be added by another user when this happens.
The issue is that some of our government departments don't want separate invoices so we have to put multiple client services on a single invoice

Regards,

Integrity
 
I have a field in a table where I want to lock the record called LOCKED_BY_USER
When this record get accessed, I check if it is empty (NULL)

[pre]
If it is NULL
I put UserName into it and this record is mine
Make Update command button enabled
Else (there is a sombody else’s UserName in it)
I display a message “The record is locked by [name from the locking field]”
Make Update button unavailable
Else If
[/pre]
When I leave an Update Form, or move to another record, I first ‘clean’ LOCKED_BY_USER field with my name in it.


Have fun.

---- Andy
 
Hi Andrzejek,

Thanks for your reply.

I tried using this code

Code:
Private Sub Form_Load()
 
If LockedbyUser Is Not Null Then
Save.visible = false

else

End If
Save.visible = true
'Turn the MouseWheel Off
Dim blRet As Boolean
blRet = MouseWheelON


End Sub

But cant get this to work. How can I do something like this without using any other command button to work

Thank you
Integrity







 
The correct syntax is:
If Not IsNull(LockedbyUser) Then

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Even if you use PHV suggestion, your logic is wrong :-(
You set your (what I assume is a commend button) Save to be Visible outside If-The-Else-End if, so it will always be visible

Code:
Private Sub Form_Load()
 
If IsNull(LockedbyUser) Then 
    cmdSave.Visible = True[green]
    'Update LockedbyUser field with UserName[/green]
else
   cmdSave.Visible = False
   MsgBox "Record locked by" & LockedbyUser
End If[green]
'Save.visible = true
'Turn the MouseWheel Off[/green]
Dim blRet As Boolean
blRet = MouseWheelON

End Sub

Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top