Hello karthikcoep,
The way to do this is keep the serial number in a separate file. This provides exclusive user access as only one user can have the file open at a time. It also allows all users to read and write the same serial number. The serial number file is a single line text file that can be stored on the server. Create the file using NotePad and enter the current serial number and save the file where you and others can access it. Change the string variable SNfile in the macro to the path of this file (include the file name and extension with the path). Here are the 2 macro to get the serial number and update it. The text box for the serial number has its Locked property set to True. This allows only the code to change the serial number and not the user.
Function GetSN()
Dim FSO As Object
Dim SN As Double
Dim SNfile As Variant
Dim TS As Object
SNfile = "C:\Documents And Settings\Admin.ADMINS\My Documents\Query Serial Number.txt"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set TS = FSO.OpenTextFile(SNfile, 1, True, -2)
GetSN = TS.ReadLine
TS.Close
Set FSO = Nothing
End Function
Sub UpdateSN()
Dim FSO As Object
Dim SN As Variant
Dim SNfile As String
Dim TS As Object
SNfile = "C:\Documents And Settings\Admin.ADMINS\My Documents\Query Serial Number.txt"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set TS = FSO.OpenTextFile(SNfile, 1, False, -2)
SN = TS.ReadLine
TS.Close
Set TS = FSO.OpenTextFile(SNfile, 2, False, -2)
TS.WriteLine SN + 1
TS.Close
Set FSO = Nothing
Set TS = Nothing
End Sub
Bookmarks