Solved

data report

Posted on 2000-05-07
6
341 Views
Last Modified: 2012-08-13
Well,assume there is a employees table(emp.mdb),which contains details of all employees of a particular company.
I want to print a report containing the details of a specific employee,say with employee number 30(empno is the key field of this table) using data report.

further assume that the employee number will b supplied by the user through a text box.there is a command button(cmdprint) in the form, which accepts empno.

My doubt is how to give the sql statmnt inside the command object,so as to print the details of the desired employee?
0
Comment
Question by:muthu76
6 Comments
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
0
 

Expert Comment

by:mdmurphy
Comment Utility
emoreau,
I have tried to hammer the data report into what I needed it to do, but gave up and made a small investment in Acttive Reports--I have recommended this tool many time here in EE.
Good Luck.
MDMurphy
0
 

Author Comment

by:muthu76
Comment Utility
went to the link suggested by emoreau
and got the answer.
i hav another doubt in this regard.
if there r multiple conditions to b included in the sql,how should it b done?

say, i want a report which contains the details of an employee with id=15 and age > 25?
both r accepted from the user?
how to include it within the sql stmnt,in the command obj of data environmnt?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 2

Accepted Solution

by:
chris_a earned 50 total points
Comment Utility
I have been playing with these, mainly because I needed async execution. I may have got you answer along the way

I have a complex report that calls a complex SP with parameters, about as bad as it can be.

The code below makes an ADO shaping connection thru SQL server to run a customized ADO/SQL string, asynchronously.

Esentially, modify the connection string and RS source from the data report.

Sorry this is not too clear, but it give you the pointers you need.

########################################

    If deReport.rsGrandTotal.State = adStateOpen Then
        deReport.rsGrandTotal.Close
    End If
   
    If deReport.cnnReport.State = adStateOpen Then
        deReport.cnnReport.Close
    End If
   
    connstr = _
            "Provider=MSDataShape;Data Provider=MSDASQL.1;Persist Security Info=False;Extended Properties=""DSN=" & _
            m_sDSN & ";UID=" & m_sUID & ";PWD=" & m_sPWD & _
            ";QueryLog_On=Yes;QueryLogTime=9000;StatsLog_On=Yes;UseProcForPrepare=0"""
' was
'   connstr = _
'           "Provider=MSDASQL.1;Persist Security Info=False;Extended Properties=""DSN=" & _
'           m_sDSN & ";UID=" & m_sUID & ";PWD=" & m_sPWD & _
'           ";QueryLog_On=Yes;QueryLogTime=9000;StatsLog_On=Yes;UseProcForPrepare=0"""
   
    If deReport.cnnReport.State <> adStateOpen Then
        deReport.cnnReport.ConnectionString = connstr
    Else
        If deReport.rsGrandTotal.State = adStateOpen Then
            deReport.rsGrandTotal.Close
        End If
    End If
   
    ' syncronous report
'    deReport.cnnReport.Open
'    deReport.GrandTotal StartDate, EndDate

' async version!    
    sqlish = _
       "SHAPE ( SHAPE {{CALL sp_qryActivationReportAllSites( '" & _
       Format$(StartDate, "dd-mmm-yyyy hh:nn:ss") & "', '" & _
       Format$(EndDate, "dd-mmm-yyyy hh:nn:ss") & _
       "') }} AS qryActivationReportAllSites COMPUTE qryActivationReportAllSites, " & _
       "SUM(qryActivationReportAllSites.'FalseAlarm') AS SumGrpFalse, " & _
       "SUM(qryActivationReportAllSites.'CommsAlarm') AS SumGrpComms, " & _
       "SUM(qryActivationReportAllSites.'IntuderAlarm') AS SumGrpIntruder, " & _
       "COUNT(qryActivationReportAllSites.'Name') AS SumGrpAll " & _
       "By 'SkyCode','Name','Programme_Type') AS qryActivationReportAllSites_Grouping " & _
       "COMPUTE SUM(qryActivationReportAllSites_Grouping.'SumGrpFalse') AS SumAllFalse, " & _
       "SUM(qryActivationReportAllSites_Grouping.'SumGrpAll') AS SumAllAll, " & _
       "SUM(qryActivationReportAllSites_Grouping.'SumGrpIntruder') AS SumAllIntruder, " & _
       "SUM(qryActivationReportAllSites_Grouping.'SumGrpComms') AS SumAllComms, " & _
       "qryActivationReportAllSites_Grouping"
   
    deReport.rsGrandTotal.Open sqlish, connstr, adOpenForwardOnly, adLockReadOnly, adCmdText Or adAsyncExecute
   
    Do While (deReport.rsGrandTotal.State <> adStateOpen) And (m_bCancel = False)
      ' heartbeat indicator
        DoEvents
    Loop
   
    If m_bCancel Then
        deReport.rsGrandTotal.Cancel
        Exit Sub
    End If

    ' put date into a MSHFlexGrid
    '    grid.DataMember = drMain.DataMember
    '    Set grid.DataSource = drMain.DataSource
   
    drMain.StartDate = StartDate
    drMain.EndDate = EndDate
   
    drMain.Show vbModeless

########################################
0
 
LVL 2

Expert Comment

by:chris_a
Comment Utility
I should add that although this is asynchronous, you cannot run two copies of the same report.

I am trying to get round this limitation at the moment. :(
0
 

Expert Comment

by:mdmurphy
Comment Utility
Chris,
This is the last time I will suggest it to you because you have already rejected my answer, but Active Reports will do what you want to do--a whole lot simpler than what I have seen in your other responses. Good Luck anyway.
MDMurphy
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now