?
Solved

Crystal reports

Posted on 1998-10-23
17
Medium Priority
?
274 Views
Last Modified: 2013-12-25
Why do I get an error message of number 20536 which has an error text of, "Unable to connect: incorrect log on parameters.  I use VB 6 nd it only happens in win'95.  It occurs on the line CR.Action = 1 on the following code:

Private Sub cmdPrint_Click()

Dim x As Integer, Ret As Integer

MousePointer = 11

On Error GoTo ErrorHandler

CR.ReportFileName = App.Path & "\ipreport.rpt"

CR.Destination = 1
CommonDialog1.CancelError = True   'If user cancels then it will not continue
CommonDialog1.Flags = cdlPDHidePrintToFile + cdlPDNoSelection + cdlPDNoPageNums + cdlPDUseDevModeCopies
CommonDialog1.ShowPrinter
CR.SelectionFormula = strCR
CR.WindowState = crptMaximized
CR.Action = 1

For x = 0 To 6
    CR.Formulas(x) = ""
Next x

MousePointer = 1

CancelledPrint:

On Error GoTo 0

MousePointer = 1

Exit Sub

ErrorHandler:
 
If Err = 32755 Then
    Resume CancelledPrint
Else
    MousePointer = 1
    Ret = MsgBox("Error " & Err & ":" & " " & Error(Err), vbCritical)
    Exit Sub
End If

MousePointer = 1

End Sub
0
Comment
Question by:andcu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
  • 4
  • +1
17 Comments
 
LVL 2

Expert Comment

by:BergJC
ID: 1487909
What type of database are you using? If you are using SQL/ODBC, you must first use the CrystalReport1.Connect method before printing the report.
0
 
LVL 2

Expert Comment

by:BergJC
ID: 1487910
Here's an example:

CrystalReport1.Connect = "DSN = Marketing;UID = Username;PWD = pass;DSQ = Administration"

**DSN is the server name.
**UID is the name you have been assigned for logging onto the SQL server.
**PWD is the password you have been assigned for logging onto the SQL server.
**DSQ is the database name if your server uses the database concept.
0
 

Author Comment

by:andcu
ID: 1487911
The problem is still occuring it is also happening in WinNT but, it wasn't before and as far as I can see I haven't changed anything?!?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:BergJC
ID: 1487912
What type of database are you using?
0
 
LVL 5

Expert Comment

by:AnswerTheMan
ID: 1487913
skip the 3 commondialog1 lines, and try
0
 

Author Comment

by:andcu
ID: 1487914
No, the same error still occurs if I comment out the three lines mentioned above.
0
 

Author Comment

by:andcu
ID: 1487915
SQL Server 6.5.
0
 
LVL 2

Expert Comment

by:BergJC
ID: 1487916
With SQL Server, you must connect to the server first, using either Connect or LogonServer. Almost always, the Connect method works best.
0
 

Expert Comment

by:zli102698
ID: 1487917
Hi, Andcu: I got the same problem with Crystal report and VB5. Have you fix the problem? If so, Please let me know. Thanks
0
 

Author Comment

by:andcu
ID: 1487918
No zli, but I'll let you know if I get to fix it - could you do the same?
0
 

Expert Comment

by:zli102698
ID: 1487919
Any luck? Andcu. I still cannot figure out yet!
0
 

Author Comment

by:andcu
ID: 1487920
zli: Mine seems to work with the connect property set.  Check yours is set and if so, double check your ODBC names i.e. DSN etc. if, of course that's what you're using.

You want a line like:

CR.Connect = "DSN=Helpdesk; UID=sa; PWD=;" (as suggested by BergJC)

Try the above UID and PWD if you are unsure what to use.  The DSN can be found in the ODBC driver details available from the control panel.
0
 
LVL 2

Expert Comment

by:BergJC
ID: 1487921
So the Connect property did work for you?
0
 

Expert Comment

by:zli102698
ID: 1487922
Any luck? Andcu. I still cannot figure out yet!
0
 
LVL 2

Accepted Solution

by:
BergJC earned 400 total points
ID: 1487923
In order to use SQL server, you must use a properly formatted Connect statement. Hopefully, Zli, your problem is the same as Andcu's. You can also investigate the LogonServer commmand, but I have always used Connect.
0
 

Author Comment

by:andcu
ID: 1487924
zli: Post your section of code and I'll see if I have any ideas though I very much doubt it.  Maybe BergJC could have a look too??
0
 

Expert Comment

by:zli102698
ID: 1487925
Andcu/BergJC: Thanks for your help. I think your suggestions are working for me.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month10 days, 14 hours left to enroll

770 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