Variant does not contain an object

Hi,

I don’t know why I’m getting this error message, this is my peace of code between the two star lines is where you shall find the line that give the error is generated. Thanks

Sub Click(Source As Button)

Dim ws As New notesuiworkspace

Dim uidoc As notesuidocument

Dim uidoc2 As notesuidocument

Dim doc As notesdocument

Dim number As String

Dim number2 As String

Dim expdate As String

Dim role As Variant

Dim purchasetype As String

Dim projectname As String

Dim category As String

Dim orderamount As Currency



Set uidoc=ws.currentdocument

Set doc = uidoc.document



If uidoc.isNewDoc Then

	uidoc.Save

End If

role = Evaluate("@IsMember('[Admin]';@UserRoles)")

purchasetype = doc.PurchaseType(0)





If role(0) = 1 And doc.BudgetCalculated(0)="No" Then

	Dim s As New notessession

	Dim projdb As notesdatabase

	Dim projdv As notesview

	Dim projdoc As notesdocument

	Set projdb=s.CurrentDatabase

	category = uidoc.FieldGetText("FinCategory")   ' get the value of the financial category field

	Set projdv = projdb.GetView("PV")   ' getting the project view

	projectname = uidoc.FieldGetText("ProjectSelection")   ' get the value of the project name/number field from the order document

	Set projdoc = projdv.GetDocumentByKey(projectname)   ' according to the project name/number value, get the correct project document from the project view

	Select Case category

	Case "Operating"

		projdoc.budgetOp_com=projdoc.budgetOp_com(0) + doc.TotCostTaxed(0)

		projdoc.TotCommitted = projdoc.TotCommitted(0) + doc.TotCostTaxed(0)

	Case "Travel"

		projdoc.budgetTrav_com=projdoc.budgetTrav_com(0) + doc.TotCostTaxed(0)

		projdoc.TotCommitted = projdoc.TotCommitted(0) + doc.TotCostTaxed(0)

	Case "Contract"

		projdoc.budgetContr_com=projdoc.budgetContr_com(0) + doc.TotCostTaxed(0)

		projdoc.TotCommitted = projdoc.TotCommitted(0) + doc.TotCostTaxed(0)

	Case "Capital"

		projdoc.budgetCap_com=projdoc.budgetCap_com(0) + doc.TotCostTaxed(0)

		projdoc.TotCommitted = projdoc.TotCommitted(0) + doc.TotCostTaxed(0)

	End Select

      ' Credit Card section

	If Not (purchasetype="Purchase Order") Then

		Dim carddv As notesview

		Dim Carddoc As notesdocument

		Dim namekey(1 To 2) As String

		Set carddv = projdb.GetView("CHL")   ' getting the card holder lookup view             

		cardholdername = uidoc.FieldGetText("CardHolder")   ' get the value of the card holder field from the order document

		temp = uidoc.FieldGetText("TotPrice")

		temp = Right$(temp, Len(temp)-1)

		orderamount = Ccur(Orderuidoc.fieldgettext("TotGst")) * Ccur(temp)   ' get the total price field for the order and multiply it by 1.06 for the GST

		namekey(1) = purchasetype

		namekey(2) = cardholdername

		Set Carddoc = carddv.GetDocumentByKey(namekey)    ' according to the value of purchase type and card holder name, get the correct cardholder document from the card holder view

		Select Case purchasetype

		Case "MasterCard"

			Carddoc.RemCreditM = Carddoc.RemCreditM(0) - orderamount   ' substract the orderamount from the remaining credit

		Case "VISA"

			Carddoc.RemCreditV = Carddoc.RemCreditV(0) - orderamount   ' substract the orderamount from the remaining credit

		End Select

	End If

	

	doc.BudgetCalculated="Yes"

	projdoc.Save True, True

	If Not (Carddoc Is empty) Then

		Carddoc.Save True, True

	End If

End If

doc.Save True, True

End Sub

Subject: Variant does not contain an object

Try this:Turn on the debugger,

Step through the code.

When you get to the line in question, look at the variables. One of them will not be set and that tells you where your problem is and you should be able to figure out how to fix the problem.

Subject: RE: Variant does not contain an object

yes I know that ‘orderamount’ and ‘temp’ are not set…but do they have to?

Subject: Variant does not contain an object

It looks like you are not setting Orderuidoc anywhere in the code

Subject: RE: Variant does not contain an object

I agree, Orderuidoc is not set. Therefore you cannot get a field from it.

Subject: RE: Variant does not contain an object

yes effectively that was the problem, thank you very much all of you for your help.