【问题标题】:Saving Listview contents to ms access db将 Listview 内容保存到 ms access db
【发布时间】:2013-07-24 14:04:02
【问题描述】:

我已将另一个列标题添加到我的列表视图VAT,它从另一个表加载并填充到列表视图。到目前为止,一切正常。现在,我正在尝试将列表视图中的信息保存到另一个表中,但事实证明这很困难。

我已经在网上搜索了一个星期,但这里是我加载到 listview 的代码。

Public Sub cmdLookup_Click()
On Error GoTo SearchError

With Connect.rsitem
 .Filter = "Itemno = '" & txtSearch.Text & "' or desc1 like '" & txtSearch.Text & _
     "*' or desc2 like '" & txtSearch.Text & "*' or upc = '" & txtSearch.Text & "'"
  
     .Open
    If .RecordCount > 1 Then
       FrmSearch.Show vbModal
   End If
   If .RecordCount > 0 Then
      QtyRemain = !onhandqty
   If QtyRemain > 0 Then
         Set x = ListView.ListItems.Add(, , !itemno)
            x.SubItems(1) = !desc1
            x.SubItems(2) = !desc2
            x.SubItems(3) = !Size
            x.SubItems(4) = 1
            x.SubItems(5) = FormatNumber(!unitprice)
            x.SubItems(6) = FormatNumber(!unitprice)
            x.SubItems(7) = !upc
            x.SubItems(8) = !Vat
            x.EnsureVisible
            x.Selected = True

保存部分

Public Sub SaveSales()
Dim i As Integer
i = 1
 Do Until i = (ListView.ListItems.Count + 1)
 With ListView.ListItems(i)
       Connect.AddSales txtinvoice.Text, .Text, .SubItems(4), .SubItems(6), txtdate.Text, txtSubTotal.Text, _
                     txtDiscount.Text, txtTotal.Text, frmPayment.txtCash.Text, _
                     CDbl(frmPayment.txtCash.Text) - CDbl(txtTotal.Text), "Open", frmLogin.Cashier
 End With
i = i + 1
   Loop
End Sub

【问题讨论】:

  • 什么/哪里出错了?
  • 没有错误,我正在尝试包括我在列表视图中添加的增值税以保存在表格中。我不知道该怎么做是 vb 的新手...谢谢
  • 当我尝试添加 .SubItems(8) 时出现错误,没有数据成员。有人请帮忙
  • Connect.AddSales 是什么?是否调整为接收附加参数.SubItem(8)
  • @George 是的,没错

标签: ms-access listview vb6


【解决方案1】:

终于可以正常工作了,从数据环境调整 SQL 参数以包含“Vat”,即“.subitems(8)”。谢谢乔治

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-30
    • 2014-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多