Variable will not take assignment

Problem.String variable won’t take on assigned value.

i.e tmp_var = “XYZ” won’t work.

Background.

I have a function which runs in the “Exiting” event of an editable text field.

The function arguments are the field contents as a string value and a newly created notes document.

The goal of the function is to allow the user to enter a description instead of a code and have the system locate the appropriate code and place the code into the edit field.

This function is in a library which is “used” in the declaration area of a form.

Call Example.

Sub Exiting(Source As Field)

'

If BillOfLadingFieldQuit(uidoc.FieldGetText("sdBillOfLading"), fieldExitDoc) Then

	Call uidoc.Document.ReplaceItemValue("sdEntry_Date",fieldExitDoc.GetItemValue("sdBL_Date"))	

	'

	uidoc.refresh

Else	

	Messagebox("Cound not find Bill Of Lading Code")

End If

End Sub

Function Code.

Function BillOfLadingFieldQuit(plookfor As String, rDoc As NotesDocument) As Boolean

	Dim  SupplierShipmentDB As NotesDatabase

	Dim ShippingDocsView As NotesView

	Dim  ndoc As NotesDocument

	Dim ResultDoc As NotesDocument, ResultDocList As NotesDocumentCollection

	'

	On Error Goto ErrHandler

	'

	If SupplierShipmentDB Is Nothing Then Set SupplierShipmentDB = uiws.CurrentDatabase.Database

	Set ShippingDocsView = SupplierShipmentDB.Getview("vwShippingDocument.Index")

	'

	If Len(Trim(plookfor)) = 0 Then

		'Do nothing...

	Else

		Dim qString As String, tmp_key As String, tempvar As Variant, qvalue As String

		tmp_key = Trim(plookfor)

		

		Set ResultDoc = ShippingDocsView.GetDocumentByKey(tmp_key,True)

		If ResultDoc Is Nothing Then 'Search against shipment documents

			If Left(tmp_key,1) = "?"  Then

				tmp_key = Strrightback(tmp_key,"?") '<- problem is here

				qString = "FIELD Form = frmShippingDocument and FIELD sdBillOfLading contains " & tmp_key '<- problem is here

				Set ResultDocList = SupplierShipmentDB.Ftsearch(qString, 0)

			Else

				Set ResultDocList = ShippingDocsView.GetAllDocumentsByKey(tmp_key, False)

			End If

		End If

		'

		If ResultDocList.Count > 1 Then 'Narrow down count... 

			qvalue = ""

			Set ndoc = ResultDocList.Getfirstdocument()

			Do

				qvalue = qvalue + ndoc.Getfirstitem("sdVessel_Name").values(0)

				qvalue = qvalue + " [" + ndoc.Getfirstitem("sdBillOfLading").values(0) + "];"

				Set ndoc = ResultDocList.Getnextdocument(ndoc)

			Loop Until ndoc Is Nothing

			'

			Set ndoc = SupplierShipmentDB.CreateDocument()

			Call ndoc.Replaceitemvalue("SearchResult", qvalue)

			Call ndoc.Replaceitemvalue("SearchText", tmp_key)

			Call ndoc.Replaceitemvalue("ResultChoice", "")

			Call ndoc.Replaceitemvalue("SearchChoice", "01")

			'

			If uiws.Dialogbox("dlgBillofLadingSearch", False, False, False, True, False, False, "Find Bill of Lading...", ndoc, False, False, False) Then

				tmp_key = Trim(ndoc.Getfirstitem("ResultChoice").Text)

				Set ResultDoc = ShippingDocsView.Getdocumentbykey(tmp_key, False)					

			End If

		Elseif ResultDocList.Count = 1 Then

			Set ResultDoc = ResultDocList.Getfirstdocument()

		End If

		'

		If ResultDoc Is Nothing Then

			Print "Bill of Lading:"+tmp_key+" Not found..."

		Else

			Set rDoc = ResultDoc

		End If			

		

	End If		

ExitFunction:

	BillOfLadingFieldQuit = Not (ResultDoc Is Nothing)

	Exit Function

ErrHandler:

	Error Err, Error & Chr(13) + "Module: " & Cstr( Getthreadinfo(1) ) & ", Line: " & Cstr( Erl )

	Resume ExitFunction

End Function

Option Public and Option Declare are on.

When I view this function in the debugger, variables “tmp_key” and “qString” don’t take on an value when the assignment statement is reached.

I’m really hoping I’ve made an error somewhere and that this is not the 8.5.2 LS compiler having a fit.

I’ve actually copied and modified this code from an existing function, which is working. What I don’t understand is why the straight forward assignment statements don’t work.

Any help gratefully received.

Subject: Confusion

Hi Wayne

Your code says …

if Left(tmp_key,1) = “?” Then

tmp_key = Strrightback(tmp_key,“?”)

but if the first character is a ? (which is what’s in your IF) then why not do

tmp_key = mid$( tmp_key, 2 )

Plus, I’m guessing

qString = "FIELD Form = frmShippingDocument and FIELD sdBillOfLading contains " & tmp_key

should be rewritten

qString = |FIELD Form = “| & frmShippingDocument & |” and FIELD “| & sdBillOfLading & |” contains " & tmp_key

kind regards

Simon Delicata

Subject: Confusion…

Simon

"Your code says …

if Left(tmp_key,1) = “?” Then

tmp_key = Strrightback(tmp_key,“?”)"

The user can type a question mark followed by some text to have the app perform an internal search. This piece of code removes the “?” from the beginning of the text if it is there.

The assignment:

qString = "FIELD Form = frmShippingDocument and FIELD sdBillOfLading contains " & tmp_key

“frmShippingDocument” and “sdBillOfLading” are not variables, they’re field names.

The problem I have is that “qString” is not being assigned.

I thought it might be that I have the variables defined elsewhere, but they are dim’md in the function and should be local.