BjLim010182
Programmer
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
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"
.Item("txtDate"
.Item("txtDate"
.Item("txtInvNum"
.Item("txtInvNum"
.Item("txtQty"
.Item("txtQty"
.Item("txtloose"
.Item("txtloose"
End With
'With .Sections("section4"
' .Item("Lblprod"
'End With
'With .Sections("section7"
' .Item("label9"
'End With
.Orientation = rptOrientPortrait
.Show
.WindowState = 2
End With
End Sub