Link to home
Start Free TrialLog in
Avatar of dspavlik
dspavlik

asked on

Selecting Data for a report duriing run

Here is that code I have.  I am trying to be able to generate a list of employees base on the office selected.  Why does this not work and what so I need to do to fix it.  TIA


Private Sub Command1_Click()
    Load DataEnvironment1
    DataEnvironment1.Agents ("SELECT * FROM Agents WHERE OfficeID = '" & Office & "'")
    Load DataReport1
    DataReport1.Visible = True
End Sub
Avatar of beckingh
beckingh

You'll need to establish a connection to the database that houses your "AGENTS" table.  Then query the database through that connection, get back a recordset with the result of the query, and pass the result to your report.

Here's a link to some code that portends to simplify ADO database access.

http://vbcode.com/asp/showsn.asp?theID=1000
Avatar of dspavlik

ASKER

That is what I am try to do. I thought that the code did that agents is actually a command of the dataenvironment maybe that is where i am going wrong
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Do u have acommand named Agents,if not create a command in the dataenvironment
Private Sub Command1_Click()
   Load DataEnvironment1
str1="SELECT * FROM Agents WHERE OfficeID = '" & Office & "'"
if DataEnvironment1.rscommand1.state<>0 then DataEnvironment1.rscommand1.close
   DataEnvironment1.rscommand1.Open str1
   DataEnvironment1.Agents ("SELECT * FROM Agents WHERE OfficeID = '" & Office & "'")
   Load DataReport1
   datareport1.refresh
   DataReport1.show
End Sub

Hope this helps
dspavlik, you abandoned the questions:

https://www.experts-exchange.com/jsp/qShow.jsp?ta=msaccess&qid=20107774
https://www.experts-exchange.com/jsp/qShow.jsp?ta=msaccess&qid=20094809
https://www.experts-exchange.com/jsp/qShow.jsp?ta=msaccess&qid=20094260
https://www.experts-exchange.com/jsp/qShow.jsp?ta=javascript&qid=20134879
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20149309
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20147999
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20127161
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20123591
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20112558
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20101686
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20094157
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20038446
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20029752
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20008417
https://www.experts-exchange.com/jsp/qShow.jsp?ta=html&qid=20034882
https://www.experts-exchange.com/jsp/qShow.jsp?ta=networkgen&qid=20078536
https://www.experts-exchange.com/jsp/qShow.jsp?ta=networkgen&qid=20078533
https://www.experts-exchange.com/jsp/qShow.jsp?ta=networkgen&qid=20063493
https://www.experts-exchange.com/jsp/qShow.jsp?ta=networkgen&qid=20054270
https://www.experts-exchange.com/jsp/qShow.jsp?ta=networkgen&qid=11337557
https://www.experts-exchange.com/jsp/qShow.jsp?ta=netware&qid=20075338
https://www.experts-exchange.com/jsp/qShow.jsp?ta=netware&qid=20051986
https://www.experts-exchange.com/jsp/qShow.jsp?ta=netware&qid=11519078
https://www.experts-exchange.com/jsp/qShow.jsp?ta=lotusnotes&qid=11655379

please clear them up.

cjswimmer
It's time to clean up this topic area and that means taking care of this question. Your options at this point are:

1. Award points to the Expert who provided an answer, or who helped you most. Do this by clicking on the "Accept Comment as Answer" button that lies above and to the right of the appropriate expert's name.

2. PAQ the question because the information might be useful to others, but was not useful to you. To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.

3. Delete the question because it is of no value to you or to anyone else.  To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.

If you elect for option 2 or 3, all you need to do is post right here as a comment, and I will take care of the rest.  We also request that you review any other open questions you might have and deal with them as necessary.

PLEASE DO NOT AWARD THE POINTS TO ME.

____________________________________________

 

Hi Experts:

In the event that the Asker does not respond, I would very much appreciate your opinions as to which Expert ought to receive points (if any) as a result of this question.  Likewise, you can also suggest that I PAQ or delete the question.

Experts, please do not add further "answer" information to this question.  I will be back in about one week to finalize this question.

Thank you everyone.

Moondancer - Community Support Moderator @ Experts Exchange
I deserve this one (You need to Refresh the report. Read this article: http://support.microsoft.com/support/kb/articles/Q244/7/79.ASP). The given article explain exactly this problem.
Force accepted by:
Moondancer
Community Support Moderator @ Experts Exchange