在集合中找不到请求名称或序号的项



从数据网格中单击客户端后,所有客户端信息都加载在表单的右侧,一切似乎都很好。[https://i.stack.imgur.com/Mv5ZL.png][1]

每当我点击添加付款按钮时,它就会打开付款单。[https://i.stack.imgur.com/DmznP.png][2]

但每当我尝试选择另一个客户端时,它都会产生运行时错误"3265"。当我单击debug按钮时,要填充的字段似乎已经包含了所需的所有信息。为什么会出现此错误?[https://i.stack.imgur.com/YuLg5.png][3]

这是我在加载所有客户端时的代码

Private Sub Form_Load()
Set Connect = New Class1
Set rx = New ADODB.Recordset
rx.Open "SELECT * FROM allclients ORDER by dateCreated ASC", con, 3, 3
lblLNumberRecords.Caption = Format(rx.RecordCount, "###,###,###.##")
Set DatCUSTOMERS.DataSource = rx
Me.Show
clearfields
End Sub

这是我点击客户端时的代码:

Private Sub DatCUSTOMERS_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
Unload frmPaymentRecur
lblID = rx.Fields("id")
txtClientID = rx.Fields("clientCode")
txtFirstName = rx.Fields("fname")
txtLastName = rx.Fields("lname")
txtMname = rx.Fields("mname")
txtExtension = rx.Fields("extName")
txtPin = rx.Fields("pinNo")
txtDesignation = rx.Fields("designation")
txtContactNo = rx.Fields("contactNo")
txtAddress = rx.Fields("address")
txtAge = rx.Fields("Age")
txtSalary = rx.Fields("salary")
cmbAssociation.Text = rx.Fields("fieldTypeTitle")
cmbChoices.Text = rx.Fields("fieldNameTitle")
cmdEdit.Enabled = True
cmdAddLoan.Enabled = True
cmdPayments.Enabled = True
End Sub

这是我点击添加付款按钮时的代码:

Private Sub cmdPayments_Click()
Dim flagClients, dateFlag, loanFlag As Integer
flagClients = 1
dateFlag = 1
loanFlag = 1
frmPaymentRecur.lbldateFlag.Caption = dateFlag
frmPaymentRecur.lblLoanFlag.Caption = loanFlag
frmPaymentRecur.txtClientID = rx.Fields("clientCode")
frmPaymentRecur.txtFolderNo = rx.Fields("folderCode")
frmPaymentRecur.txtFullName = rx.Fields("Name")
frmPaymentRecur.txtAssociation = rx.Fields("fieldNameTitle")
frmPaymentRecur.txtSalary = rx.Fields("salary")
frmPaymentRecur.CmbSelectPaymentType.Text = "All Loans"
frmPaymentRecur.lblFlag = flagClients
If rx.State = 1 Then rx.Close
rx.Open "SELECT DISTINCT(`Loan Type`) FROM paymentview WHERE `Client Code` = '" & Trim$(txtClientID.Caption) & "'", con, 3, 3
With rx
Do While Not .EOF
frmPaymentRecur.CmbSelectPaymentType.AddItem ![Loan Type]
.MoveNext
Loop
.Close
End With
frmPaymentRecur.Show
End Sub

在添加付款代码的末尾,您将关闭rx记录集。当您尝试更新控件时,它将为空。

您还使用来自另一个表paymentview的数据填充了记录集,其中id可能不存在。

您应该创建一个单独的记录集来处理您的支付代码,而不是重复使用rx记录集。

相关内容

  • 没有找到相关文章

最新更新