Hi,
I'm putting together a simple db report to list the top 10 items, in order, in the report.
I've got the code i need to calulate the spacing and listing etc. but i'm stuck with actually getting the correct data I need.
I have form with two boxes on it, txtFrom and txtTo, I want to input a date in each and the report list the top 10 transactions between this data range.
The code below that i'm using at the minute is working fine, until I put the "Between" into the sql. It basically ignores it!
Could someone let me know what i could do to get around this, i've tried basing the .openrecordsets onto a query i've created but it tells me there's too few arguements, expected 2, or that it cannot find the query.
Any help would be appreciated!
Here's the code:
I'm putting together a simple db report to list the top 10 items, in order, in the report.
I've got the code i need to calulate the spacing and listing etc. but i'm stuck with actually getting the correct data I need.
I have form with two boxes on it, txtFrom and txtTo, I want to input a date in each and the report list the top 10 transactions between this data range.
The code below that i'm using at the minute is working fine, until I put the "Between" into the sql. It basically ignores it!
Could someone let me know what i could do to get around this, i've tried basing the .openrecordsets onto a query i've created but it tells me there's too few arguements, expected 2, or that it cannot find the query.
Any help would be appreciated!
Here's the code:
Code:
Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)
Dim strContracts As String
Dim intIndex As Integer
strsql = "Select * FROM tblScrap WHERE (((tblScrap.[transqty]) >0)) ORDER BY tblScrap.TransQty;"
With CurrentDb.OpenRecordset(strsql)
For a = 1 To 10
intIndex = intIndex + 1
If Len(a) > 1 Then
If Len(![Item-no]) = 4 Then
strContracts = strContracts & CStr(intIndex) & ". " & ![Item-no] & Space((15 - Len(a) + 1.5) - Len(![Item-no])) & UCase(![TransQty]) & Space((15 - Len(a) + 1.5) - Len(![TransQty])) & UCase(![Description1]) & vbNewLine
Else
strContracts = strContracts & CStr(intIndex) & ". " & ![Item-no] & Space((15 - Len(a) + 1.5) - Len(![Item-no]) - Len(a)) & UCase(![TransQty]) & Space((15 - Len(a) + 1.5) - Len(![TransQty])) & UCase(![Description1]) & vbNewLine
End If
Else
If Len(![Item-no]) = 4 Then
strContracts = strContracts & CStr(intIndex) & ". " & ![Item-no] & Space((15 - Len(a) + 1.5) - Len(![Item-no])) & UCase(![TransQty]) & Space((14 - Len(a) + 1.5) - Len(![TransQty])) & UCase(![Description1]) & vbNewLine
Else
strContracts = strContracts & CStr(intIndex) & ". " & ![Item-no] & Space((15 - Len(a) + 1.5) - Len(![Item-no]) - Len(a)) & UCase(![TransQty]) & Space((14 - Len(a) + 1.5) - Len(![TransQty])) & UCase(![Description1]) & vbNewLine
End If
End If
.MoveNext
Next
End With
Me.txtTopAdjustments = strContracts
End Sub