|
8#
楼主 |
发表于 2012-7-23 18:36:34
|
只看该作者
感谢大家,深受启发现在把我的解决办法提供一下,办法很笨,但也简单:
Private Sub StrDsql()
Dim SS1, SS2, SS3, SS4, SS5, SS6, SS7, SS8 As String
Dim iii, XH, PH, HH, Cb3 As Integer
If XmLx = "二维" And Cb01.Value = "按线号" Then
QSql = Sql1 & Sql2 & WHSql & Str01 & Str02 & Str04 & ODSql2X
End If
If XmLx = "三维" And Cb01.Value = "按线号" Then
QSql = Sql1 & Sql2 & WHSql & Str01 & Str02 & Str04 & ODSql3X
End If
If XmLx = "三维" And Cb01.Value = "按排号" Then
QSql = Sql1 & Sql2 & WHSql & Str01 & Str02 & Str04 & ODSql3P
End If
'以下是生成的qsql的语句
'print qsql
'SELECT a.线号, a.类型, b.子线号, b.设计线号, b.设计点号, b.简化桩号, a.点号, '278队/2012年' AS 队号,
'0 AS 序号, 0 AS 分栏, 0 as 分行 FROM 测线设计数据 AS a LEFT JOIN 设计物理点列表 AS b ON a.重新设计ID = b.ID
'where (a.类型 in ('G','S')) and a.项目ID= 51 and a.成果数据ID>0 and b.设计线号='2085' and val(b.设计点号)>=2001 and val(b.设计点号)<=2392 ORDER BY b.设计线号, b.设计点号
Sql = "DELETE 打印桩号临时表.* FROM 打印桩号临时表"
DoCmd.RunSQL Sql
Set Rst01 = DbTemp.OpenRecordset(QSql)
Rst01.MoveFirst
XH = 0
Cb3 = Rst01.RecordCount \ 3
If (Rst01.RecordCount Mod 3) > 0 Then Cb3 = Cb3 + 1
Do While Not Rst01.EOF
XH = XH + 1
HH = XH Mod Cb3
If HH = 0 Then HH = Cb3
If HH = Cb3 Then PH = (XH \ Cb3) Else PH = (XH \ Cb3) + 1
SS1 = Rst01.Fields("线号").Value
SS2 = Rst01.Fields("类型").Value
SS3 = Rst01.Fields("点号").Value
SS4 = Rst01.Fields("设计线号").Value
SS5 = Rst01.Fields("设计点号").Value
SS6 = Rst01.Fields("子线号").Value
SS7 = Rst01.Fields("简化桩号").Value
SS8 = Rst01.Fields("队号").Value
If PH = 1 Then
Sql = "insert into 打印桩号临时表 (队号,列1序号,列1行号,列1线号,列1点号,列1简桩) values " _
& "('" & SS8 & "'," & str(XH) & "," & str(HH) & ",'" & SS1 & "','" & SS3 & "','" & SS7 & "')"
DoCmd.RunSQL Sql
End If
If PH = 2 Then
Sql = "update 打印桩号临时表 as a " _
& "set a.列2序号=" & str(XH) _
& ", a.列2行号=" & str(HH) _
& ", a.列2线号=" & "'" & SS1 & "'" _
& ", a.列2点号=" & "'" & SS3 & "'" _
& ", a.列2简桩=" & "'" & SS7 & "'" _
& " where a.列1行号=" & str(HH)
DoCmd.RunSQL Sql
End If
If PH = 3 Then
Sql = "update 打印桩号临时表 as a " _
& "set a.列3序号=" & str(XH) _
& ", a.列3行号=" & str(HH) _
& ", a.列3线号=" & "'" & SS1 & "'" _
& ", a.列3点号=" & "'" & SS3 & "'" _
& ", a.列3简桩=" & "'" & SS7 & "'" _
& " where a.列1行号=" & str(HH)
DoCmd.RunSQL Sql
End If
Rst01.MoveNext
Me.桩号打印_子窗体.Requery
Loop
Rst01.Close
Me.桩号打印_子窗体.Requery
End Sub
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|