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

Help!! Saving a dialog box as a new document

Status
Not open for further replies.

gem28

Instructor
Nov 5, 2001
64
PH
Hi!
Please help, I've really stomped on this one. :(
I have 2 forms, the main form and a dialogbox-acting form.

The dialog box inherits the values from the main document. It is then saved, supposedly, as a separate document.
However, what happens is that it only replaces the document earlier saved.

This is the script I used:
Sub Click(Source As Button)
Dim ws As New NotesUIWorkspace
Dim s As New NotesSession
Dim db As notesdatabase
Dim uidoc As notesuidocument
Dim dc As notesdocument
Dim doc As NotesDocument
Dim view As NotesView
Dim propKey As String

Set uidoc = ws.currentdocument
Set db = s.CurrentDatabase
Set doc = uidoc.document

Set view = db.GetView("pb")
propKey = uidoc.FieldGetText ("propKey")
Set dc = view.GetDocumentByKey (propKey)
rankNo = doc.rankNo(0)
userName = doc.rankNo(0)

Call uidoc.FieldSetText ("bStatus","booked")
Call doc.Save (True,False)
Call ws.ViewRefresh
Call uidoc.close
End Sub

I'm really running out of ideas. :( Please, please help.
Thanks so much!

tin
 
First remark : a dialog box is not a document per se, it is used to update the original document as the functionality of the method.

Second remark : where do you use the dialog box method ? The code you show just opens a document, sets a field value and closes the same document. You declare and do a view search for another document (dc), but once you have it your code doesn't do anything with it.

Pascal.


I've got nothing to hide, and I'd very much like to keep that away from prying eyes.
 
The dialog box is used to notify the current user of his rank no for an item that he's trying to reserve. I also need to save this document dialog box to keep track of how many users have reserved and the properties they reserved.
Fortunately, I was able to figure out to resolve this. Please check the script below:

Sub Click(Source As Button)
Dim ws As New NotesUIWorkspace
Dim s As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim tmpdoc As NotesDocument
Dim uidoc As NotesUIDocument
Dim rankCode As String
Dim oldRank, newRank, totalRank As Integer
Dim newdoc As NotesDocument 'new

Set uidoc = ws.CurrentDocument
Set db = s.CurrentDatabase
Set view = db.GetView( "pb" )

rankCode = uidoc.FieldGetText ("RefCode")
Set doc = view.GetDocumentByKey( rankCode, True )

oldRank = 1
If doc Is Nothing Then
Call uidoc.FieldSetText ("rankNo", Cstr(oldRank))
Else
' ---- for computation of the rank no. ----
newRank = Cint(uidoc.FieldGetText ("rankNo"))
totalRank = newRank + 1
Call uidoc.FieldSetText ("rankNo", Cstr(totalRank))
Call uidoc.FieldSetText ("userName",s.UserName)
End If

Set newdoc = New NotesDocument (db)
Set doc = uidoc.Document
Call uidoc.Save
' --- setting values for the new document ---
newdoc.refnum = doc.RefCode(0)
newdoc.userName = doc.userName(0)
newdoc.rankNo = doc.rankNo(0)
newdoc.pCreateDate = doc.pCreateDate(0)
newdoc.pCreateTime = doc.pCreateTime(0)
newdoc.propKey = doc.parentKey(0)

'Call uidoc.Save
Call ws.DialogBox( "dp", True, True, True, False, False, False, "INFORMATION",newdoc,False,True)
Call uidoc.Close
End Sub

Now, I'm trying to work on data validation. I'm trying to make a script that when a user clicks the button for an item which he has reserved already, the system will display a another message box notifying him that he cannot do the process anymore.

Thanks so much for your time! :)

tin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top