Creating a TOM table within an interview

Recently the following question was asked in LinkedIn :

KG: Some years ago I saw an interview script that produced a TOM table and presented the information to the respondent. You might use this to show poll results when a respondent has answered a question. For the life of me I can not find that script. Does anyone have an example of this that I can use?

and it got the following response from

CB : I haven’t found the example, but here’s code to connect to a database and pull in the results. You’d need to adjust the code inside the If but I’m sure you could take that result and display it:

Dim rsquery, sSQL, oConnection, oRecordSet
Set oConnection = CreateObject("Adodb.connection")
Set oRecordset = CreateObject("ADODB.Recordset")

    oConnection.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Initial Catalog=MyDatabase;Data Source=MyServer"
    oConnection.Open()
    sSQL = "Select * FROM [MyDatabase].[dbo].[MyTable]"

    Set rsQuery=oConnection.Execute(sSQL)
    If rsQuery.BOF=False Then'Found record(s)
        sampBusunit =cText(rsQuery.Fields["Busunit"])
    End if
oConnection.Close()

This is a great reply as it shows one way , not using TOM , but a way that will work. If however you realy need to use TOM then you can do something like this once your table is created. To see how to create the table take a look at this post , but once you have your table object you can use the HTMLRenderer to do the rest for you.

Dim HtmlRenderer,sTomHTML


Set HtmlRenderer = CreateObject("ExportHtml.Renderer")
    HtmlRenderer.DisplayAnnotations = False
    HtmlRenderer.DisplayOption = 0              ' 0 = Table Only
    HtmlRenderer.EmbedCss = true
			
    HtmlRenderer.UseFormattedLabels = True
    HtmlRenderer.IncludeTitleBlock = False
    HtmlRenderer.IncludeTOC = False
    HtmlRenderer.OutputBodyOnly = True
			
    sTomHTML = replace(HtmlRenderer.Render(oTableDoc.GetTablesXml(sTable)),mr.newline,"")
		
    Set HtmlRenderer = Null

I do this sort of stuff all the time and it works well , I normally take the output data and run it through the Highcharts api. to produce charts etc. Oh and don’t forget this will only work in your survey if you have TOM on the server. To get an idea of what I do , take a look at this.

Speeding up your Excel Exports

With speed about the mrExcelExport always a hot topic when you write your TOM scripts i thought i would take a look at another possability of getting your tables into Excel. In this article i will show you how you can use the “mrTextExport” to export your tables , and also sugest something you could do to the exising Excel Export to speed it up.

Read more

Add Context , Populate & Strip HTML out

You would have recently seen in LinkedIn that Barb asked the following question. “When you add html code into your survey, it displays beautifully but then it displays as code in your tabs. Is there a way in a DMS to globally eliminate any HTML code?” and I pointed him to a post that had been written awhile ago. Also in my comment I mentioned that I had a script that would add a context to an MDD and then strip out the HTML and put just the text in it. This article shows you the code for that script.

Read more

Learn Tables : HTML Export

In the next set of articles that i will write we will look at all the diffetent type of exports we can use. At the time of writing there are five types of export , html, text, excel, powerpoint and word. It is also possible to write your own type of exports and if you want some info on that let us know and we will point you in the write direction. In this article we will look at the HTML export and all the features you can use.

Read more

Learn Tables : Filters

In the previous article we looked at how to tabulate the questions in our survey. When we create tables it is often that we don’t want to tabulate all the data but a subset of it. In this article we will look at how we can create those sub sets of data so that we can filter our tables at the global level or at the table level.

Read more

Learn Tables : Basic Tables

In our last article we showed you the steps that you need to take to produce tables in Data Collection. Open the data , create the table structure , populate the tables and then export. In this article we will spend some time showing you how to create some of the different tables that you may need and some of the basic additions that we need to add to our script to make it run smother.

Read more

%d bloggers like this: