Problem - Sending query results to Report

  • Thread starter Combo box type - help
  • Start date
C

Combo box type - help

i'm having some trouble sending the data i got from a query to a the report..
i have a form where i can input de month and year i want to query from the
data base.. Then i have this button:

Private Sub visual_Click()
If IsNull(DLookup("Mes", "Table1_Query")) Then
MsgBox "Não há registo para esta data! #No records match this
combination!#"
Else
Report_Report2.relano.SetFocus
Report_Report2.relano = DLookup("[ano]", "Table1_Query")
Report_Report2.relmes.SetFocus
Report_Report2.relmes = DLookup("[mes]", "Table1_Query")
Report_Report2.relirr.SetFocus
Report_Report2.relirr = DLookup("[Irradiância média]", "Table1_Query")
Report_Report2.relpot.SetFocus
Report_Report2.relpot = DLookup("[Potência Produzida]", "Table1_Query")
Report_Report2.relhoras.SetFocus
Report_Report2.relhoras = DLookup("[Nº de horas de sol]", "Table1_Query")
Report_Report2.reltemp.SetFocus
Report_Report2.reltemp = DLookup("[Temperatura]", "Table1_Query")
Report_Report2.relfact.SetFocus
Report_Report2.relfact = (DLookup("[Potência Produzida]", "Table1_Query")) /
(DLookup("[Tarifa]", "Table1_Query"))
DoCmd.OpenReport "Report2", acViewReport
End If
End Sub

its suppose to check if the month and year inputed are already registered in
the database, and if they are and the record was found and sent to the query
i would like to send every value connected to that "date" i searched from the
query to the report textboxes.. i made the code as good as i know..but it's
not working.. the follouwing error message is appearing "Microsoft office
access doesnt allow you to use this method in the current view"..

P.s.-I already tried inputing on the end of the command to open the report
to add acviewreport, acview normal, acviewpreview and also doesnt work..
Please help..
Many thanks..
NM
 
D

Douglas J. Steele

See whether changing Report_Report2 to Reports("Report2") makes a
difference. (I'm assuming that Report2 is open when this code is running. If
it's not, the code will definitely not work.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top