Hello,
When I tried to Import the data from the spreadsheet, I got the ‘Type Mismatch’ errorit is retrieving the data ‘Data Ref No.’ as a key value (in the first column)
Warm Regards,
Sarathi
Hello,
When I tried to Import the data from the spreadsheet, I got the ‘Type Mismatch’ errorit is retrieving the data ‘Data Ref No.’ as a key value (in the first column)
Warm Regards,
Sarathi
Subject: Type Mismatch
Hi Sarathi,
A common cause for a type mismatch is assigning data of one type (string, date etc.) to the value of a variable declared as another type.
We need to see your code to be more specific. Can you post it?
John
Subject: RE: Type Mismatch
Hello John,
Thanks for your response,
Below is the respective code.
Dim ansact As String
Dim aColRef As String
Dim adDoc As NotesDocument
Dim adDocView As notesview
Dim adModuleDoc As NotesDocument
Dim adResultsSource As String
Dim bareakey As String
Dim cellValue As String
Dim commentsAction As String
Dim commentsColRef As String
Dim completedBy As String
Dim cModKey As String
Dim finalRowNum As Long
Dim probar As ProgressBar
Dim qref As QuestionReference
Dim questionRefColRef As String
Dim rowNum As Double
'// Get the aud document
'Set currDb = session.CurrentDatabase
Set adDocView = g_AppCurrDb.GetView(VIEW_ADDOCBYID_LOOKUP)
Set adDoc = adDocView.GetDocumentByKey(g_CurrentAdDocID)
'// Get the column IDs
questionRefColRef = g_DialogDoc.GetItemValue("QuestionRefColumn")(0)
aColRef = g_DialogDoc.GetItemValue("AnswerColumn")(0)
commentsColRef = g_DialogDoc.GetItemValue("CommentsColumn")(0)
'// Get details of the results source
adResultsSource = g_DialogDoc.GetItemValue("AdResultsSource")(0)
completedBy = g_DialogDoc.GetItemValue("CompletedBy")(0)
'// Get the final row and action details
finalRowNum = Clng(g_DialogDoc.GetItemValue("LastQuestionRow")(0))
ansact = g_DialogDoc.GetItemValue("Ansact")(0)
commentsAction = g_DialogDoc.GetItemValue("CommentsAction")(0)
'// Start the progress bar
Set probar = New ProgressBar(Clng(finalRowNum),"Importing ad details from the spreadsheet.")
'// Step through all of the rows in the spreadsheet starting at 1
For rowNum = 1 To finalRowNum
'// Get the question reference
cellValue = Cstr(g_ExcelDocObj.Worksheets(1).Range(questionRefColRef & Cstr(rowNum)).Value)
’ cellValue = Cstr(g_ExcelDocObj.Worksheets(1).Range(questionRefColRef & Cdbl(rowNum)).Value)
Print cellValue
If cellValue <> "" Then
Set qref = New QuestionReference(cellValue)
If qref.IsValid Then
Call probar.UpdateProgress("Importing from row " & Cstr(rowNum))
'// Get the ad module document if this question is for a different module
If cModKey <> qref.ModuleKey Or bareakey <> qref.Bareakey Then
'// Save the current adModuleDoc if it is open
If Not (adModuleDoc Is Nothing) Then
Call s_SaveAdModuleDoc(adDoc, adModuleDoc, adResultsSource, completedBy)
End If
'// Find the adModuleDoc for this module
Set adModuleDoc = s_GetAdModuleDoc(adDoc, qref.Bareakey, qref.ModuleKey)
If adModuleDoc Is Nothing Then
bareakey = ""
cModKey = ""
Else
bareakey = qref.Bareakey
cModKey = qref.ModuleKey
End If
End If
'// Update the question details
If Not (adModuleDoc Is Nothing) Then
'// Update the comments
If commentsAction <> "none" Then
’ Call s_UpdateAdQuestion(adModuleDoc, “Comments”, qref, commentsAction, Cdbl(rowNum), commentsColRef)
Call s_UpdateAdQuestion(adModuleDoc, "Comments", qref, commentsAction, Cstr(rowNum), commentsColRef)
End If
'// Update the answer
If ansact <> "none" Then
Call s_UpdateAdQuestion(adModuleDoc, "Answer", qref, ansact, Cstr(rowNum), aColRef)
End If
End If
Else
Call probar.UpdateProgress("Skipping row " & Cstr(rowNum))
End If
End If
Next
'// Save the current ad module document
If Not (adModuleDoc Is Nothing) Then
Call s_SaveAdModuleDoc(adDoc, adModuleDoc, adResultsSource, completedBy)
End If
'// Update the ad status if it is complete
If s_IsAdComplete(adDoc) = True And adDoc.GetItemValue("AdStatus")(0) = "New" Then
Call adDoc.ReplaceItemValue("AdStatus","Complete")
Call adDoc.Save(True,False)
End If
Call s_AppMsgBox("Import complete !", 64, "Import Complete")
Call probar.Complete
End Sub