Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Report Problem

Status
Not open for further replies.

BjLim010182

Programmer
Joined
Aug 18, 2002
Messages
2
Location
PH
I was able to get that howto thing microsoft posted but I don't understand it.

This is what I'm doing. I created a data report and added a group. Then, on a form, I have a command button that shows that form. My code works well if I remove the group from the data report but if I dont I get an error message that says something about the data structure doesn't match.

Here is my code. Hope you can help me.


Private Sub cmdProdHist_Click()
Dim ProdChosen As String

ProdChosen = InputBox("Enter Product:", "Product")

Call Open_Connection

rsSales.CursorLocation = adUseClient
rsSales.CursorType = adOpenDynamic
rsSales.LockType = adLockPessimistic

rsSales.Open "SELECT Date, [sales invoice number], [product name], Quantity " _
& "FROM SALES WHERE [product name] like '" & ProdChosen & "%' group by [sales invoice number], [product name], date, quantity", cn



With rptProdHist
Set .DataSource = rsSales
.DataMember = ""


With .Sections("Section1").Controls
.Item("txtDate").DataMember = ""
.Item("txtDate").DataField = rsSales.Fields(0).Name
.Item("txtInvNum").DataMember = ""
.Item("txtInvNum").DataField = rsSales.Fields(1).Name
.Item("txtQty").DataMember = ""
.Item("txtQty").DataField = rsSales.Fields(3).Name
.Item("txtloose").DataMember = ""
.Item("txtloose").DataField = rsSales.Fields(2).Name

End With

'With .Sections("section4").Controls
' .Item("Lblprod").Caption = rsSales.Fields(2).Value
'End With

'With .Sections("section7").Controls

' .Item("label9").Caption = "txtQty"

'End With

.Orientation = rptOrientPortrait
.Show
.WindowState = 2

End With

End Sub
 
I notice one of your fieldnames is "Date", which is a reserved word. I've had trouble in the past where I've used reserved words as fieldnames or table names. Try using a different name...

Hope this helps,
Ralph
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top