Solved

Access Report w/ VB

Posted on 2002-03-11
6
162 Views
Last Modified: 2013-11-28
  Dim acc As Access.Application
   Set acc = CreateObject("Access.Application")
   acc.OpenCurrentDatabase("c:\data.mdb")
   appAccess.DoCmd.OpenReport "Item Report, acPreview
   appAccess.Visible = True

This code work fine but if data.mdb have database password
this code have little bit problem. My question is how
to open report with database pass in it.

Thanks
0
Comment
Question by:ekohartono
  • 3
  • 3
6 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6855787
use this:

Const dbPathName = "c:\database.mdb"
Const strPassword = "PASSWORD"
Dim Acc As Object, db As Object

Set Acc = CreateObject("Access.Application")
Set db = Acc.Application.DBEngine.Workspaces(0).OpenDatabase(dbPathName, 0, False, ";pwd=" & strPassword)
Acc.OpenCurrentDatabase dbPathName, False
Set db = Nothing
Acc.DoCmd.OpenReport "ReportName", acPreview
Set Acc = Nothing
0
 

Author Comment

by:ekohartono
ID: 6856865
Thanks Emoreau
Your Code Help Me
I still Have 1 Question I hope You Don't Mind To Help Me Again.
In Crystal Report We Can Design Filter Like Code at bottom

Crystalreport1.selectionformula="{item.code} like 'EL*' and {item.Date} = date(" & year(vardate) & ","
& month(vardate) & "," & day(vardate) & ")"


That WeCan Change In Run Time So We Can Arrange Report That We Need. Can We Do It In Access Report ?

Thank You

0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 50 total points
ID: 6857003
change this line:
Acc.DoCmd.OpenReport "ReportName", acPreview

to:
Acc.DoCmd.OpenReport "ReportName", acPreview,, "="item.code like 'EL*'"
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

Author Comment

by:ekohartono
ID: 6860959
Thank's Lot
Can I Do Like This ?

Acc.DoCmd.OpenReport "ReportName",acPreview,, "="item.code like 'EL*'" and item.date like '02/02/02'"
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6861012
date datatype are not working with the Like operator.

also dates must be enclosed between #
0
 

Author Comment

by:ekohartono
ID: 6869602
To Emoreau

There is away to open report without open MS Access ?
Because if I use DoCmd.OpenReport I will See A Report And if i Minimize Report Window I Can Choose Tables Object So Any One Can Change My Database.
My Question At
http://devx.experts-exchange.com/jsp/qManageQuestion.jsp?ta=visualbasic&qid=20276662


Thank You
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

773 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