Receive error when double click data in Listbox - excel

I am newbies in VBA. Recently I have created a "Search Form". The search data have 21 columns which will display in the "Search List Box". Unfortunately, it only can show until 9 columns and will return an error for the 10 and above data. Your guidance is very much appreciated. Below is my code:
Private Sub dtlist_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
CDSv1.dptname.Text = CDSv1.dtlist.Column(1)
CDSv1.dptadd.Text = CDSv1.dtlist.Column(2)
CDSv1.divcom.Text = CDSv1.dtlist.Column(3)
CDSv1.ctcname.Text = CDSv1.dtlist.Column(4)
CDSv1.ctcno.Text = CDSv1.dtlist.Column(5)
CDSv1.nid.Text = CDSv1.dtlist.Column(6)
CDSv1.serno.Text = CDSv1.dtlist.Column(7)
CDSv1.ipinfo.Text = CDSv1.dtlist.Column(8)
CDSv1.snet.Text = CDSv1.dtlist.Column(9)
CDSv1.gateway.Text = CDSv1.dtlist.Column(10) '<---- The error starts here.
CDSv1.vlinfo.Text = CDSv1.dtlist.Column(11)
CDSv1.netcatcom.Text = CDSv1.dtlist.Column(12)
CDSv1.netsubcatcom.Text = CDSv1.dtlist.Column(13)
CDSv1.ispcom.Text = CDSv1.dtlist.Column(14)
CDSv1.snscom.Text = CDSv1.dtlist.Column(15)
CDSv1.cirt.Text = CDSv1.dtlist.Column(16)
CDSv1.bdwh.Text = CDSv1.dtlist.Column(17)
CDSv1.statcom.Text = CDSv1.dtlist.Column(18)
CDSv1.remf.Text = CDSv1.dtlist.Column(20)
End Sub

Related

How can i add this other condition to this code?

i have this subroutine that i use to make labels. for some reason i cant just make another subroutine where instead of "CGI_SAMPLE_LABEL" it uses "YCI_SAMPLE_LABEL" because of other subroutines. any suggestions on how i can add this so that it chooses either one or the other. if tried using WHERE OR but that didn't work. i edited some of the tags because LIMS basic language is also like smalltalk.
LabelType = "CGI_SAMPLE_LABEL"
pTableNameStr = "SAMPLE"
pLabelNameStr = "CGI_SAMPLE_LABEL"
'Breakpoint(aReason)
NumSamples = Ubound(selectedObjects, 1)
FOR X = 1 TO NumSamples
SampleNumber = selectedObjects[x]
pKeyNameArr[1] = SampleNumber
pNumLabelsInt = 1
pLabelNameStr = "CGI_SAMPLE_LABEL"
pReasonStr = "Auto Label Generation"
pActivityStr = "Label printed for sample logged event"
GOSUB FN_LABEL_PRINT_ALL
NEXT 'Sample
RETURN

Repeating formula over a range

Sub Test3()
Range("C23").Formula = "=SUM(C16:C22)"
Range("D23").Formula = "=SUM(D16:D22)"
Range("E23").Formula = "=SUM(E16:E22)"
Range("F23").Formula = "=SUM(F16:F22)"
Range("G23").Formula = "=SUM(G16:G22)"
Range("H23").Formula = "=SUM(H16:H22)"
Range("I23").Formula = "=SUM(I16:I22)"
Range("K16").Formula = "=J16-C23"
Range("K17").Formula = "=J17-D23"
Range("K18").Formula = "=J18-E23"
Range("K19").Formula = "=J19-F23"
Range("K20").Formula = "=J20-G23"
Range("K21").Formula = "=J21-H23"
Range("K22").Formula = "=J22-I23"
End Sub
How do I simplify this code?
If you are asking whether your code can be simplified, then yes. For the first group, you can use this instead...
Range("C23:I23").Formula = "=SUM(C16:C22)"
For the second one, you can use this...
Range("K16:K22").Formula = "=SUM(J16-INDEX($C$23:$I$23, ROWS(K$16:K16)))"

DocuSign REST API full name tag

I am creating an envelope using DocuSign REST API with two recipients. Each recipient has two sets of tags - sign here tag and a full name tag.
When an envelope gets created, the sign here tags are showing up correctly for both recipients but the the full name tags for the second recipient is showing up for the first recipient.
I am passing the correct document id and recipient id for both tags in the API request.
Adding my code here..
Public Function SetSignerProperties(ByVal signer As Recipient) As DocuSign.eSign.Model.Signer
Dim dssigner As New DocuSign.eSign.Model.Signer
If Not signer Is Nothing Then
dssigner.Name = signer.name
dssigner.Email = signer.email
dssigner.AccessCode = signer.accesscode
dssigner.AddAccessCodeToEmail = signer.addAccessCodeToEmail
dssigner.Note = signer.note
dssigner.RoutingOrder = signer.routingOrder
dssigner.RecipientId = signer.recipientrecid
If signer.IsCaptiveRecipient Then
dssigner.ClientUserId = signer.recipientrecid
dssigner.EmbeddedRecipientStartURL = signer.embeddedRecipientStartURL
End If
'set up the signer tabs..
AddRecipientTags(signer, dssigner)
End If
Return dssigner
End Function
Public Function AddRecipientTags(ByVal recp As Recipient, ByVal signer As DocuSign.eSign.Model.Signer)
If Not signer Is Nothing Then
If Not recp.tabs Is Nothing Then
signer.Tabs = New DocuSign.eSign.Model.Tabs
For Each currtab In recp.tabs
Select Case currtab.tabType
Case "Sign Here"
'it is a signer tab..
If signer.Tabs.SignHereTabs Is Nothing Then
signer.Tabs.SignHereTabs = New List(Of DocuSign.eSign.Model.SignHere)
End If
Dim signheretab As New DocuSign.eSign.Model.SignHere
If Not currtab.anchorIgnoreIfNotPresent Is Nothing Then
signheretab.AnchorIgnoreIfNotPresent = currtab.anchorIgnoreIfNotPresent
End If
signheretab.AnchorString = currtab.anchorString
signheretab.AnchorUnits = currtab.anchorUnits
signheretab.AnchorXOffset = currtab.anchorXOffset
signheretab.AnchorYOffset = currtab.anchorYOffset
signheretab.ConditionalParentLabel = currtab.conditionalParentLabel
signheretab.ConditionalParentValue = currtab.conditionalParentValue
signheretab.Name = currtab.name
signheretab.Optional = currtab.toptional
signheretab.PageNumber = currtab.pageNumber
signheretab.RecipientId = currtab.recipientId
signheretab.ScaleValue = currtab.scaleValue
signheretab.TabId = currtab.tabId
signheretab.TabLabel = currtab.tabLabel
signheretab.TabOrder = currtab.tabOrder
signheretab.XPosition = currtab.xPosition
signheretab.YPosition = currtab.yPosition
signheretab.DocumentId = currtab.documentId
signer.Tabs.SignHereTabs.Add(signheretab)
Case "Full Name"
If signer.Tabs.FullNameTabs Is Nothing Then
signer.Tabs.FullNameTabs = New List(Of DocuSign.eSign.Model.FullName)
End If
Dim tab As New DocuSign.eSign.Model.FullName
If Not currtab.anchorIgnoreIfNotPresent Is Nothing Then
tab.AnchorIgnoreIfNotPresent = currtab.anchorIgnoreIfNotPresent
End If
tab.AnchorString = currtab.anchorString
tab.AnchorUnits = currtab.anchorUnits
tab.AnchorXOffset = currtab.anchorXOffset
tab.AnchorYOffset = currtab.anchorYOffset
If Not currtab.bold Is Nothing Then
tab.Bold = currtab.bold
End If
tab.ConditionalParentLabel = currtab.conditionalParentLabel
tab.ConditionalParentValue = currtab.conditionalParentValue
tab.DocumentId = currtab.documentId
tab.Font = currtab.font
tab.FontColor = currtab.fontColor
tab.FontSize = currtab.fontSize
tab.PageNumber = currtab.pageNumber
tab.RecipientId = currtab.recipientId
tab.Name = currtab.name
tab.TabId = currtab.tabId
tab.TabLabel = currtab.tabLabel
tab.TabOrder = currtab.tabOrder
tab.XPosition = currtab.xPosition
tab.YPosition = currtab.yPosition
If Not currtab.underline Is Nothing Then
tab.Underline = currtab.underline
End If
signer.Tabs.FullNameTabs.Add(tab)
End Select
Next
End If
End If
End Function
Please advise,
Thanks,
Minal

Dynamic excel chart doesn't display all of the data

I have this code that allows users to enter chart parameters into some cells and dynamically create a chart. Many series (up to four) are allowed on two vertical (y) axis and one shared horizontal (x) axis. The chart is a mixture of columns and lines normally, and the data ranges are of varying length. I have this code that adds the series like so (I'll try to stick to what I believe is the relevant code)
seriesCount = 1
If hasSeries1 = True Then
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(seriesCount).Name = .Cells(2, 6) & " " & axisside1
ActiveChart.SeriesCollection(seriesCount).ChartType = chartType1
ActiveChart.SeriesCollection(seriesCount).AxisGroup = axisgroup1
ActiveChart.SeriesCollection(seriesCount).Border.LineStyle = borderStyle1
ActiveChart.SeriesCollection(seriesCount).Border.Color = lineColor1
ActiveChart.SeriesCollection(seriesCount).Format.Line.Weight = lineWidth1
ActiveChart.SeriesCollection(seriesCount).Format.Fill.ForeColor.RGB = seriesColor1
ActiveChart.SeriesCollection(seriesCount).Format.Line.Visible = hasLine1
ActiveChart.SeriesCollection(seriesCount).XValues = dates1
ActiveChart.SeriesCollection(seriesCount).Values = dataset1
seriesCount = seriesCount + 1
End If
If hasSeries2 = True Then
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(seriesCount).Name = .Cells(3, 6) & " " & axisside2
ActiveChart.SeriesCollection(seriesCount).ChartType = chartType2
ActiveChart.SeriesCollection(seriesCount).AxisGroup = axisgroup2
ActiveChart.SeriesCollection(seriesCount).Border.LineStyle = borderStyle2
ActiveChart.SeriesCollection(seriesCount).Border.Color = lineColor2
ActiveChart.SeriesCollection(seriesCount).Format.Line.Weight = lineWidth2
ActiveChart.SeriesCollection(seriesCount).Format.Fill.ForeColor.RGB = seriesColor2
ActiveChart.SeriesCollection(seriesCount).Format.Line.Visible = hasLine2
ActiveChart.SeriesCollection(seriesCount).XValues = dates2
ActiveChart.SeriesCollection(seriesCount).Values = dataset2
seriesCount = seriesCount + 1
End If
If hasSeries3 = True Then
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(seriesCount).Name = .Cells(4, 6) & " " & axisside3
ActiveChart.SeriesCollection(seriesCount).ChartType = chartType3
ActiveChart.SeriesCollection(seriesCount).AxisGroup = axisgroup3
ActiveChart.SeriesCollection(seriesCount).Border.LineStyle = borderStyle3
ActiveChart.SeriesCollection(seriesCount).Border.Color = lineColor3
ActiveChart.SeriesCollection(seriesCount).Format.Line.Weight = lineWidth3
ActiveChart.SeriesCollection(seriesCount).Format.Fill.ForeColor.RGB = seriesColor3
ActiveChart.SeriesCollection(seriesCount).Format.Line.Visible = hasLine3
ActiveChart.SeriesCollection(seriesCount).XValues = dates3
ActiveChart.SeriesCollection(seriesCount).Values = dataset3
seriesCount = seriesCount + 1
End If
If hasSeries4 = True Then
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(seriesCount).Name = .Cells(5, 6) & " " & axisside4
ActiveChart.SeriesCollection(seriesCount).ChartType = chartType4
ActiveChart.SeriesCollection(seriesCount).AxisGroup = axisgroup4
ActiveChart.SeriesCollection(seriesCount).Border.LineStyle = borderStyle4
ActiveChart.SeriesCollection(seriesCount).Border.Color = lineColor4
ActiveChart.SeriesCollection(seriesCount).Format.Line.Weight = lineWidth4
ActiveChart.SeriesCollection(seriesCount).Format.Fill.ForeColor.RGB = seriesColor4
ActiveChart.SeriesCollection(seriesCount).Format.Line.Visible = hasLine4
ActiveChart.SeriesCollection(seriesCount).XValues = dates4
ActiveChart.SeriesCollection(seriesCount).Values = dataset4
End If
Here is the problem: the chart only displays part of the data it is supposed to. When I right-click on the data series, hit Select Data and choose Edit, the correct series (both x and y) become highlighted, but what is being shown is a truncated subset of what should be there.
Here is a sample of what I'm seeing
Here is some of the data for the light blue column
12/30/2005 307%
1/31/2006 302%
2/28/2006 248%
3/31/2006 262%
4/28/2006 285%
5/31/2006 256%
... ...
... ...
... ...
6/30/2014 147%
Notice how this data should be showing on the chart beginning at 12/30/2005, but it's starting at 11/30/2013 instead (though the values appear to be correct, 307%, 302%, etc.). It is almost as though excel is forcing the 2nd and 3rd data series to be the same length as the first one. The first one is charting correctly.
I think you're not using a XY chart, thus you must have the same labels (Xvalues = dates for you) for every series. That means that you need to create a unique dates-set containing all the dates and assign it (as Xvalues) to the first serie.

How to write data to existing Sharepoint 2007 Calender List

Domestic demand,We must let our develop system form copy to the WSS 3.0 Calendar list
Simply put, I know need to use ADO to update [Alluserdata] this table and also know whitch
tp_listId.
However, after updating, has written to the database, it can not appear in Sharepoint page
What am I do some thing wrong...
ps: suspected tp_size field related, but not sure ....
Public Sub Pm_woToSharePoint(ByVal PM_WO_MAIN_VIEWRow As PM_WO_MAIN_VIEW)
Try
Dim cdataobj As New cDataACCESS
Dim dt_Prolist As Data.DataTable
Dim selectString As String
selectString = "select top 1 * from AllUserData where tp_listId='4C0516DB-B090-4740-A0F0-B99E6DC31C0C' order by tp_id desc"
dt_Prolist = cdataobj.sqlDt(selectString, "SharepointConnectionString")
Dim CalenderListRow As Data.DataRow = dt_Prolist.NewRow
Dim CalenderListRow2 As Data.DataRow = dt_Prolist.Rows(0)
With CalenderListRow2
CalenderListRow.Item("tp_ID") = .Item("tp_id") + 1
CalenderListRow.Item("tp_ListId") = .Item("tp_ListId")
CalenderListRow.Item("tp_SiteId") = .Item("tp_SiteId")
' CalenderListRow.Item("tp_RowOrdinal") = 0
CalenderListRow.Item("tp_Version") = 1
CalenderListRow.Item("tp_Author") = 96
CalenderListRow.Item("tp_Editor") = 96
CalenderListRow.Item("tp_Modified") = Now
CalenderListRow.Item("tp_Created") = Now
CalenderListRow.Item("tp_Ordering") = DBNull.Value
CalenderListRow.Item("tp_ThreadIndex") = DBNull.Value
' CalenderListRow.Item("tp_HasAttachment") = 0
'CalenderListRow.Item("tp_ModerationStatus") = 0
CalenderListRow.Item("tp_IsCurrent") = 1
CalenderListRow.Item("tp_ItemOrder") = 100 * CalenderListRow.Item("tp_ID")
CalenderListRow.Item("tp_InstanceID") = DBNull.Value
' CalenderListRow.Item("tp_GUID") = 4
' CalenderListRow.Item("tp_CopySource") = DBNull.Value
'CalenderListRow.Item("tp_HasCopyDestinations") = DBNull.Value
CalenderListRow.Item("tp_AuditFlags") = DBNull.Value
CalenderListRow.Item("tp_InheritAuditFlags") = DBNull.Value
CalenderListRow.Item("tp_Size") = .Item("tp_Size")
CalenderListRow.Item("tp_WorkflowVersion") = 1
CalenderListRow.Item("tp_WorkflowInstanceID") = DBNull.Value
CalenderListRow.Item("tp_DirName") = .Item("tp_DirName")
CalenderListRow.Item("tp_LeafName") = CStr(CalenderListRow.Item("tp_ID")) & "_.000"
CalenderListRow.Item("tp_DeleteTransactionId") = .Item("tp_DeleteTransactionId")
CalenderListRow.Item("tp_ContentType") = .Item("tp_ContentType")
CalenderListRow.Item("tp_ContentTypeId") = .Item("tp_ContentTypeId")
CalenderListRow.Item("nvarchar1") = PM_WO_MAIN_VIEWRow.ITEM_NAME & " " & PM_WO_MAIN_VIEWRow.ITEM_VALUE
CalenderListRow.Item("nvarchar3") = PM_WO_MAIN_VIEWRow.ST_NAME_CHT
CalenderListRow.Item("ntext2") = "機台:" & PM_WO_MAIN_VIEWRow.MS_NAME_CHT & " 生產人員:" & PM_WO_MAIN_VIEWRow.ProductPerson
CalenderListRow.Item("datetime1") = DateAdd(DateInterval.Hour, -8, CType(PM_WO_MAIN_VIEWRow.START_TIME, DateTime))
CalenderListRow.Item("datetime2") = DateAdd(DateInterval.Hour, -8, CType(PM_WO_MAIN_VIEWRow.END_TIME, DateTime))
CalenderListRow.Item("int1") = 0
' CalenderListRow.Item("int2") = .Item("int2")
CalenderListRow.Item("bit1") = 0
CalenderListRow.Item("bit2") = 0
CalenderListRow.Item("bit3") = 0
CalenderListRow.Item("tp_Level") = 1
CalenderListRow.Item("tp_IsCurrentVersion") = 1
CalenderListRow.Item("tp_UIVersion") = 512
CalenderListRow.Item("tp_CalculatedVersion") = 0
CalenderListRow.Item("tp_UIVersionString") = "1.0"
CalenderListRow.Item("tp_DraftOwnerId") = DBNull.Value
CalenderListRow.Item("tp_UIVersionString") = DBNull.Value
CalenderListRow.Item("tp_CheckoutUserId") = DBNull.Value
End With
dt_Prolist.Rows.Add(CalenderListRow)
cdataobj.ExecSQL(dt_Prolist, selectString, "SharepointConnectionString")
Catch ex As System.Exception
Throw
End Try
End Sub
You are on totally the wrong track here accessing the database directly, its dangerous and unsupported.
The correct way to do things like this is the object model or web services (or client object model in 2010) - see here and here to get started.
This is for 2010, but its identical steps 2007 - How to add a event to a SharePoint 2010 Calendar
SPListItem newEvent = yourCalendar.Items.Add();
newEvent["Location"] = "This is location";
newEvent["Start Time"] = DateTime.Now;
newEvent["End Time"] = DateTime.Now.AddHours(1);
newEvent["Description"] = "Going for Meting";
newEvent["Title"] = "New Meting";
newEvent["fAllDayEvent"] = false;
newEvent["Category"] = "Meting";
//Create Event in the sharpoint.
newEvent.Update();

Resources