Stupidest mistake ever

Hello everyone…

I’m hoping someone can help me. I have a good feeling that I’m doing something so unbeleivably stupid that I just can’t see it.

here is my code:

Dim originalApps As String

Dim uidoc As Notesuidocument

Dim workspace As New NotesUIWorkspace

Set uidoc = workspace.CurrentDocument

originalApps = uidoc.FieldGetText(“OriginalApps”)

If originalApps = “” Then

'do lots of stuff

End If

it is dying on the ‘If originalApps = “” Then’ saying there is a type mismatch. I’ve changed it to:

originalApps Is Null

originalApps Is Nothing

originalApps Is Empty

all with the same result.

can someone please point out what I’m doing wrong? It would be greatly appreceiated.

Subject: Stupidest mistake ever…

How about skipping the string declaration and just doing this:

If uidoc.FieldGetText(“OriginalApps”) = “” then

'do your code

End If

Subject: RE: Stupidest mistake ever…

b/c eventually I’ll have an elseif depending on the value of the string…so it makes it easer to expand the code if I odn’t have to keep putting that in my code.

that, and it doesn’t work.

Subject: Stupidest mistake ever…

Do you know if there is a field by that name on every document?Try using NotesItem and get values from there.

Subject: RE: Stupidest mistake ever…

100% positive.

it is doing it with my integers too.

I decided to do my compairing first and came up with this code:

pos = Instr(originalApps, some string)

If Isnull(pos) Then…

and I’m still getting a type mismatch. This is becomeing very fustrating.

Subject: Stupidest mistake ever…

That should work. I’d probably start by creating a test scenario with a document where I knew the field had a value and then printing the value of originalApps immediately after assigning a value to it. If you die there then something is horribly wrong, if you don’t then maybe you are being mislead as to which line you’re dying on or something.

This would work just as well if the field didn’t have a value except for the part where you couldn’t be sure you actually printed anything. I guess you could try printing:

“Field Value: “”” & originalApps & “”“”"

and then you could test both an empty field and a non-empty field scenario. Might be only blowing up when it’s empty…

Another thought would be to explicitly initialize originalApps to “”. LotusScript should do that for you when you dim it but I’m paranoid that way. :slight_smile:

Or you could stick the if block above the value assignment. This means you’d always fall into the “is empty string” block but just for debugging purposes this would tell you if you’re going to get a type mismatch when testing a string variable to see if it is an empty string no matter what (in which case, I’d probably just set my computer on fire) or if the issue is arising after you assign the value.

Good luck!

Subject: Stupidest mistake ever…

I’ve figured it out. Spelling mistake somewhere, and it was complaining about that line for some reason. I don’t totally understand why, but that’s how it goes.

thanks everyone for debugging for me :slight_smile:

Subject: RE: Stupidest mistake ever…

So actually, as is so often the case, your original error was caused by failure to use Option Declare, which in my book is a hangin’ offense.

It was also a mistake in retyping your code when posting here rather than copy/paste.

However, I don’t think you’re even in the running for stupidest mistake ever, even if we limit it to Domino development. I’ve seen many blunders far more amazing in this forum.

Subject: *I have to agree with Andre on three counts: Option Declare, copying and not stupidest by far.

Subject: Stupidest mistake ever…

I can’t see anything wrong with your code. I’d recommend following things through very carefully in the debugger so that you can see just what values and data types your code is turning up. I can only suppose that something really weird is going on with the OriginalApps field which is causing data type problems.