
- Forum
- Programming Talk
- Microsoft .NET
- Object Variable or With block variable not set
Object Variable or With block variable not set
This is a discussion on Object Variable or With block variable not set within the Microsoft .NET forums, part of the Programming Talk category; Call CSetField(cobj_x_User_Data_Interact, "x_txtPANFAN", csNull) The variable cobj_x_User_Data_Interact is not declared. The above line executes the below code. Sub CSetField( cobj ...
-
Object Variable or With block variable not set
Call CSetField(cobj_x_User_Data_Interact, "x_txtPANFAN", csNull)
The variable cobj_x_User_Data_Interact is not declared. The above line executes the below code.
Sub CSetField( cobj As ContextualObject, fld_name As String, vl )
Dim MyRec As Record
Set MyRec = cobj.Contents
MyRec.SetField fld_name, vl
cobj.Fill MyRec, cbFillInPlace
End Sub
I'm not getting any error in the above line.
I'm getting the error "Error Numb: 91" "Error Desc: Object Variable or With block variable not set" while executing the first line of below code.
For nIndex = 0 To (lstSavedCidPan.Count - 1)
sCidPan = lstSavedCidPan.ItemByIndex(nIndex)
If Trim(sFieldParse(sCidPan, 1)) = Trim(CGetField(cobj_recContact, "x_cid")) Then
gsCustomerPANFAN = sFieldParse(sCidPan, 2)
gsCustomerPANFANLastFour = sFieldParse(sCidPan, 3)
gsCustomerPANFANCCRNInd = sFieldParse(sCidPan, 4)
If IsNumeric(sFieldParse(sCidPan, 3)) Then
Call CSetField(cobj_x_User_Data_Interact, "x_txtPANFAN", sMaskPCICardLastFour(sFieldParse(sCidPan, 3)))
End If
Exit For
End If
Next nIndex
cobj_recContact also not declared. The variables in the above code is declared as shown below.
Dim nIndex As Integer
Dim lstSavedCidPan As List
Dim sCidPan As String
-
If you are getting the error "Object Variable or With block variable not set" on that first line of code which happens to be a FOR statement looping on the list, lstSavedCidPanCall CSetField(cobj_x_User_Data_Interact, "x_txtPANFAN", csNull)
I'm getting the error "Error Numb: 91" "Error Desc: Object Variable or With block variable not set" while executing the first line of below code.
For nIndex = 0 To (lstSavedCidPan.Count - 1)
sCidPan = lstSavedCidPan.ItemByIndex(nIndex)
If Trim(sFieldParse(sCidPan, 1)) = Trim(CGetField(cobj_recContact, "x_cid")) Then
gsCustomerPANFAN = sFieldParse(sCidPan, 2)
gsCustomerPANFANLastFour = sFieldParse(sCidPan, 3)
gsCustomerPANFANCCRNInd = sFieldParse(sCidPan, 4)
If IsNumeric(sFieldParse(sCidPan, 3)) Then
Call CSetField(cobj_x_User_Data_Interact, "x_txtPANFAN", sMaskPCICardLastFour(sFieldParse(sCidPan, 3)))
End If
Exit For
End If
Next nIndex
You haven't initialized the list anywhere before using it...Had your declaration of the list statement been as follows, you wouldn't have got that error as the list would have been initialized to an empty list....But, before looping through you would have to add elements to the list.
Dim lstSavedCidPan As List = New List()
HTH!!!

Reply With Quote






