I want to create LotusScript to prevent user to key in same title (PC Asset Tag) that already have in DB. Example: in DB already have PC Asset Tag IT12345, then user want to key in the same PC Asset Tag IT12345. what I want to do is if user key in the same number, the massage box appear to tell the user that already have that number and cannot be save.
Below is my code:
Sub Querysave(Source As Notesuidocument, Continue As Variant)
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim PCAssetTag As String
Dim view as NotesView
Dim col as NotesViewEntryCollection
Set uidoc = workspace.CurrentDocument
AssetTag = uidoc.FieldGetText("PCAssetTag")
'this code if textfield empty will appear the message
If ( uidoc.FieldGetText( "PCAssetTag" ) = "" ) Then
Messagebox "You must enter the PC Asset Tag number",,"Warning"
Call uidoc.GotoField( "PCAssetTag" )
continue = False
End If
'this code to validate the length in textfield when user input more then 10 character
If ( Len(AssetTag) > 10 ) Then
Messagebox "Maximum 10 characters only for PC Asset Tag number",,"Warning"
Call uidoc.GotoField( "PCAssetTag" )
continue = False
End If
I have a problem in below coding
'this code to validate text field if user key in the same number that already have in DB.
Set view = thisdb.GetView("LookupView")
Set doc = view.GetDocumentByKey(AssetTag)
If Not (doc Is Nothing) Then
MsgBox "There is already hace PC Asset Tag number " & AssetTag & "."
Continue = False
End If
End Sub
my form Name: MainForm
my view name: LookupView
textfield name: PCAssetTag
when I want try to save my form, the error massage appear “Variant does not contain an object”.
Anyone can help me, I’m beginner in LotusScript.