Hi There!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm facing a real big problem... It's the last thing I've got to do in my
project. I'm programming in VBA and I need to show a report from Access by
pressing a button, but all codes I've found doesn't work...
I'm using a special kind of code, maybe that's why it doesn't work...
Look:
"Private Sub cmdalterar_Click()
Dim areatrabalho As Workspace
Dim query As String
Dim banco As DAO.Database


Set areatrabalho = DBEngine.Workspaces(0)
Set banco = areatrabalho.OpenDatabase("c:\Lucas\db1.mdb", False, False)

query = "select * from padrão where codigo = " & txtcodigo & ""
Set dyn = banco.OpenRecordset(query)

If Not dyn.EOF Then
dyn.Edit
dyn("codigo") = txtcodigo
dyn("Nomeprest") = cboNomePrest.Text
dyn("NumFatura") = txtNumFatura
dyn("BcoPag") = cboBcoPag.Text
dyn("VencNF") = txtVencNF
dyn("MesPagto") = txtMesPagto
dyn("MesCompet") = txtMesCompet
dyn("DtAssGestor") = txtDtAssGestor
dyn("DtRecMis") = txtDtRecMis
dyn("DtAssMis") = txtDtAssMis
dyn("Nat") = cboNatureza.Text
dyn("QtdPA") = txtQtdPa
dyn("DescServ") = txtDescServ
dyn("ValorGasto") = txtValGasto
dyn("AreaCanal") = cboAreaCanal.Text
dyn("DetProd") = txtDetProd
dyn("Produto") = cboProduto.Text
dyn("CentCusto") = txtCcusto
dyn("GestorMis") = cboGestorMis.Text
dyn("GestorCanal") = cboGestorCanal.Text
dyn("SitPagto") = cboSitPag.Text
dyn("Esag") = txtEsag
dyn("Obs") = txtObs
dyn.Update"
ANd I'm trying to use this code to show the report and allow printing...
"Option Explicit

'Declaracoes API
Private Declare Function ShowWindow Lib "user32.dll" (ByVal hWnd As Long,
ByVal nCmdShow As Long) As Long
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA"
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long

'Constantes API
Private Const SW_MAXIMIZE = 3
Private Const SW_NORMAL = 1
' faça uma referência a Microsoft Access 8.0/9.0 Object Library
'Cria uma instancia do Access
Dim appAccess As Access.Application

Public Sub MaximizeAccess()
Dim hWnd As Long

hWnd = FindWindow("OMain", "Microsoft Access")
If hWnd <> 0 Then
ShowWindow hWnd, SW_NORMAL
ShowWindow hWnd, SW_MAXIMIZE
End If
End Sub


Private Sub Command2_Click()
appAccess.DoCmd.OpenReport "Pendentes", acViewNormal
End Sub"
I need a help, please!!!
 
A report is based on either a table or a query. To find out look in 'record
source' property for the report 'Pendentes'. Does this data source exist?
Your code looks strange to me, you seem to be creating a recordset from a
query but only one record since there is no loop. I dont see how this record
is getting to your report or even what the point is of having a report show a
single record.

-Dorian
 
I'm basing it on a table, and all records are brought normally to the report.
The only thing I ain't getting is how to make it appear without Access open.
As I try to show the report, I receive the error "you cannot perform this
action at this time", but, if access is open, It shows normally, inside
access, but it opens...
Is there other way to build a report and show it, without Access?
Thx a lot, man!
 
Is there other way to build a report and show it, without Access?

An Access Report has no existance outside of the Access program, no.

John W. Vinson[MVP]
 
Back
Top