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!!!
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!!!