bensewell
asked on
VB - Editing Notes Databases
I am currently trying to edit a Lotus Notes database using Notes classes. The problems are as following:
1) When trying to view the object variables I create (such as NotesItem, NotesDocument), VB comes up with the error "Object Library not Registered". Which file do I need to register to remove this error?
2) When using the ReplaceItemValue command, the value of the item is cleared, but not replaced. Also, when I view the relevant document in Lotus Notes, the form displays a cleared value, but the view displays the value before it was cleared. where does this inconsitency come from? I am using the code below:
doc_src is a NotesDocument, Text2 is a textbox containing the name of a valid item and Text3 is a textbox containing a string. This item I am trying to change is of type Text.
doc_src.REPLACEITEMVALUE Text2, Text3
I am using VB5 and Notes 4.6.2a
Thank you for any help
1) When trying to view the object variables I create (such as NotesItem, NotesDocument), VB comes up with the error "Object Library not Registered". Which file do I need to register to remove this error?
2) When using the ReplaceItemValue command, the value of the item is cleared, but not replaced. Also, when I view the relevant document in Lotus Notes, the form displays a cleared value, but the view displays the value before it was cleared. where does this inconsitency come from? I am using the code below:
doc_src is a NotesDocument, Text2 is a textbox containing the name of a valid item and Text3 is a textbox containing a string. This item I am trying to change is of type Text.
doc_src.REPLACEITEMVALUE Text2, Text3
I am using VB5 and Notes 4.6.2a
Thank you for any help
try trimming the value
ASKER
Thanks for replying, ghassan99. However, I already have a reference to notes32.tlb!
This is also already the format in which I have my statement.
I have tried another approach now, though. I used the following code:
dim newitem as object
set newitem = doc_src.GETFIRSTITEM(Text2 .Text)
newitem.Values(0) = Text3.Text
doc_src.REPLACEITEMVALUE Text2, newitem.Values
doc_src.SAVE True, False
(I did have the last line previously, I just forgot to mention it).
Do you have any idea about the inconsistency between form and views? The document properties informaiton box contains the updated values, and closing and reopening the view also does nothing to help.
This is also already the format in which I have my statement.
I have tried another approach now, though. I used the following code:
dim newitem as object
set newitem = doc_src.GETFIRSTITEM(Text2
newitem.Values(0) = Text3.Text
doc_src.REPLACEITEMVALUE Text2, newitem.Values
doc_src.SAVE True, False
(I did have the last line previously, I just forgot to mention it).
Do you have any idea about the inconsistency between form and views? The document properties informaiton box contains the updated values, and closing and reopening the view also does nothing to help.
ASKER
By the way, the new code does update the form correctly now!
Ok I'm sorry I didnt get u at first...
actrually all u need to do is this:
doc_src.REPLACEITEMVALUE Text2.text, Text3.text
actrually all u need to do is this:
doc_src.REPLACEITEMVALUE Text2.text, Text3.text
try using shift+f9 when u r in the view in notes
u can see the class in the object broswer but when u click on it, it gives an error message?
ASKER
Sorry for the confusion; I can use the Object browser with no ahssle, but the Watch window is providing error messages.
shift-f9 works, thanks.
The new code works.
shift-f9 works, thanks.
The new code works.
Try re-installing notes then
If u put the following in the watch window:
doc.any_field_name_in_doc
Does it produce an error?
doc.any_field_name_in_doc
Does it produce an error?
ASKER
This is not an extension to the question, but it may be a related problem (to help anyone bugfind). To view a field from VB, have been using the code:
dim item as Variant
item = doc_src.GETITEMVALUE(Text1 )
msgbox item(0)
which works fine. however, as an experiment, I though I would try a different approach (as I know little about these classes):
dim newitem as object
set newitem = doc_src.GETFIRSTITEM(Text1 .Text)
msgbox newitem.Values(0)
The final line generates the error "Variable uses an Automaion type not supported in Visual Basic"(458). This is not a problem, as I can work around it, but an interesting point, perhaps.
dim item as Variant
item = doc_src.GETITEMVALUE(Text1
msgbox item(0)
which works fine. however, as an experiment, I though I would try a different approach (as I know little about these classes):
dim newitem as object
set newitem = doc_src.GETFIRSTITEM(Text1
msgbox newitem.Values(0)
The final line generates the error "Variable uses an Automaion type not supported in Visual Basic"(458). This is not a problem, as I can work around it, but an interesting point, perhaps.
ASKER
ghassan99,
No, there is no error when I put this into the Watch window. It displays correctly
No, there is no error when I put this into the Watch window. It displays correctly
then when does the problem occur?
ASKER
this problem occurs when I try to view doc_src in the Watch window, or an item variable
ASKER
ghassan99,
Since I do not need the final functionality - I have completed the project anyway - Submit a, "answer" and I will award the points. Thanks for your help
Since I do not need the final functionality - I have completed the project anyway - Submit a, "answer" and I will award the points. Thanks for your help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The syntax for replaceitem:
notesItem = notesDocument.ReplaceItemV
so what u need to do:
doc_src.REPLACEITEMVALUE "ur field name in notes", Text3