Solved

Access Report w/ VB

Posted on 2002-03-11
6
157 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 69

Expert Comment

by:Éric Moreau
Comment Utility
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
Comment Utility
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 69

Accepted Solution

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

to:
Acc.DoCmd.OpenReport "ReportName", acPreview,, "="item.code like 'EL*'"
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:ekohartono
Comment Utility
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 69

Expert Comment

by:Éric Moreau
Comment Utility
date datatype are not working with the Like operator.

also dates must be enclosed between #
0
 

Author Comment

by:ekohartono
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

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

18 Experts available now in Live!

Get 1:1 Help Now