-
Oct 11th, 2018, 07:53 AM
#1
Thread Starter
Lively Member
item cannot be found in the collection corresponding
Code:
Private Sub cmdPrint_Click()
Set Record = New ADODB.Recordset
Record.Open "SELECT orno,qty,rate,tamount,Edate,cname,cmob,city,gst,pack,ck (SELECT COUNT(*) FROM Ord C2 WHERE C2.prodname <= C.prodname) AS Sno FROM Ord C where orno = '" & txtOrdNo.Text & "' ORDER BY prodname ", Connect, 1, 3
If Record.RecordCount > 0 Then
With RptOrder
Set RptOrder.DataSource = Record
.Sections("Section4").Controls("Label18").Caption = Record!gst
.Sections("Section4").Controls("Label15").Caption = Record!CName
.Sections("Section4").Controls("Label17").Caption = Record!city
.Sections("Section4").Controls("Label19").Caption = Record!cmob
.Sections("Section4").Controls("Label20").Caption = Record!orno
.Sections("Section4").Controls("Label12").Caption = Recor***** Error in this Line
.Show 1
Set Record = Nothing
End With
Exit Sub
End If
End Sub
-
Oct 11th, 2018, 08:19 AM
#2
Hyperactive Member
Re: item cannot be found in the collection corresponding
Your example seems to have cut off the portion of the code that is erroring...
There are three "collections" in your example, the Sections collection, the Controls collection, and the Recordset Fields collection.
90% chance that you're specifying a field/column name that doesn't exist. Otherwise Label12 doesn't exist.
-
Oct 12th, 2018, 12:22 AM
#3
Thread Starter
Lively Member
Re: item cannot be found in the collection corresponding
Code:
Private Sub cmdPrint_Click()
Set Record = New ADODB.Recordset
Record.Open ("SELECT " _
& "(SELECT COUNT(*) FROM [Ord] WHERE [OrderNo] like'" & lblOrderNo.Caption & "'" _
& "AND [ID] <= [T].[ID]) AS [SerNo], " _
& "* FROM [Orders ] [T] WHERE [OrderNo] like'" & lblOrderNo.Caption & "'"), Connect, 1, 3
If Record.RecordCount > 0 Then
With RptOrder
Set RptOrder.DataSource = Record
.Sections("Section4").Controls("Label15").Caption = Record!CustomerName
.Sections("Section4").Controls("Label17").Caption = Record!city
.Sections("Section4").Controls("Label18").Caption = Record!tin
.Sections("Section4").Controls("Label19").Caption = Record!ContactNo
.Sections("Section4").Controls("Label20").Caption = Record!OrderNo
.Sections("Section4").Controls("Label21").Caption = Record!Trans ------->it is exist in database also
.Show 1
Set Record = Nothing
End With
Call Orders
Exit Sub
End If
End Sub
-
Oct 12th, 2018, 01:19 AM
#4
Addicted Member
Re: item cannot be found in the collection corresponding
In fact, in addition to returning a record number, your query should not return anything else...
Because the field you want to use is not included in the select。
-
Oct 12th, 2018, 01:21 AM
#5
Re: item cannot be found in the collection corresponding
That last one does not even look like a valid sql statement.
How about you show us the line that was cut off in the first post?
At any rate though it should be as was said earlier either label12 does not exist or more likely the field name on that line is incorrect but since you cut it off in your post can only guess.
-
Oct 12th, 2018, 09:34 PM
#6
Re: item cannot be found in the collection corresponding
in the first post example trans is not a selected field in the sql
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|