Solved

Access Report w/ VB

Posted on 2002-03-11
6
163 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: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

808 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