ssql = "select .isaccount,.lsxh,.k03,Carclass.cz,.k06,.total_tran_wei,gkfy.gkf01,.k13,.CarLength,.carWidth,.isaccount,(.datef+.timef) as selledtime,.sellerName " _
      & "From Mark  " _
      & " left join gkfy on .lsxh=gkfy.lsxh and .datef=gkfy.datef " _
      & " left join Carclass on Carclass.CarType=substring(.cldm,2,1) " _
      & " where k14='" & SshipNo & "' and regularno='" & Shbh & "' and convert(varchar(10),departdate,120)='" & Sdapartdate & "' and TPQK=0 and  not loadtype='10' and isaccount = 1 " _
      & " Union all " _
      & "select backup.isaccount,backup.lsxh,backup.k03,Carclass.cz,backup.k06,backup.total_tran_wei,gkfybackup.gkf01,backup.k13,backup.CarLength,backup.carWidth,backup.isaccount,(backup.datef+backup.timef) as selledtime,backup.sellerName " _
      & "From backup  " _
      & " left join gkfybackup on backup.lsxh=gkfybackup.lsxh and backup.datef=gkfybackup.datef " _
      & " left join Carclass on Carclass.CarType=substring(backup.cldm,2,1) " _
      & " where k14='" & SshipNo & "' and regularno='" & Shbh & "' and convert(varchar(10),departdate,120)='" & Sdapartdate & "' and TPQK=0 and  not loadtype='10' and isaccount = 1 " _
      & " order by .lsxh"
Set rst0 = cn.OpenResultset(ssql, rdOpenStatic, rdConcurReadOnly, rdExecDirect)
If Not rst0.EOF Then
Dim pp As Long
pp = 500 - c_k06
If (pp) > rst0!k06 Then
If MsgBox(pp & "当前重量还可以加栽,要加栽吗?", vbYesNo + vbDefaultButton2) = vbYes Then
Dim qsql As String
qsql = "update  set loadtype = 10 where isaccount = 1 and lsxh = '" & rst0!lsxh & "' and k14='" & SshipNo & "' and regularno='" & Shbh & "' and convert(varchar(10),departdate,120)='" & Sdapartdate & "' and TPQK=0 and  not loadtype='10'"
cn.Execute qsql, rdExecDirect
    End If
    Else
    Dim strmsg As String
    strmsg = "该船单元重量只剩 " & pp & " 吨可加载" & "," & "您所选的车单重量已超" & "," & "请从新选择或停止加载"
    MsgBox strmsg, 48, "不允许加载"
    Exit Sub
    End If
我查询出来的k06若干个,上面我的代码只能点按钮一次,对第一个记录操作,我希望得到的结果是一次对符合条件的若干个经过操作,请问如何写??
比如我查询出的记录是50,10,20 我选择了50,10 但是一次只对50操作,我想同时对50,10操作

解决方案 »

  1.   

    从纷乱的代码中我只能找到错别字
    If MsgBox(pp & "当前重量还可以加栽,要加栽吗?", vbYesNo + vbDefaultButton2) = vbYes Then 加载能描述的再清楚点么?
      

  2.   

    对rst0做循环啊
    If Not rst0.EOF Then
        rst0.movefirst
        do until rst0.eof
            ......
            rst0.movenext
        loop
    end if
      

  3.   

    qsql = "update  set loadtype = 10 where isaccount = 1 and lsxh = '" & rst0!lsxh & "' and k14='" & SshipNo & "' and regularno='" & Shbh & "' and convert(varchar(10),departdate,120)='" & Sdapartdate & "' and TPQK=0 and  not loadtype='10'
    这段代码是我对记录的某个字段的修改,ssql语句是我查询出记录集,一般都是若干条,我想要的结果是:自动把符合条件的都更改状态(qsql语句中),
    比如我的pp = 50
    而我查询出来的记录有
    10,40,35,15,20,40,5,9,3,18
    而我需要得到的结果是
    10,15,20,5,3
    就是最接近与pp
    过程中pp应该是随着选择一个记录就会改变吧请问下这个算法该实现啊?
    谢谢
      

  4.   

    too longggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg