473,692 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

vb6: report open and close way too fast

Hi everyone,
Here's my problem. I have a report that i want to use with the command
openreport. The report open and close in a fraction of a second. I cant
see why i cant view the thing. Cause i can print it and all...

here's my code

Private Sub Command4_Click( )

Dim accObj As Access.Applicat ion
Dim dbs As String

dbs = App.Path & "\bouya.mdb "
Set accObj = GetObject(dbs, "Access.Applica tion")
DoCmd.OpenRepor t "rptbouya1" , acViewPreview
accObj.Visible = True

accObj.Quit
Set accObj = Nothing

End Sub

If someone could help me with this, it would be really appreciated.

Thx in advance

Jul 28 '06 #1
6 4321
Although technically it does not (exactly) work this way,
you can think of it in this manner to make some sense of it:
Access VBA does not wait for the prior command/line of code to be completed
before executing the next line.
It is only doing what you told it to do.
It begins to open your report and then you immediately tell it to close the
application.
Try commenting out the line using an apostrophe:

' accObj.Quit

I believe this command is the culprit.

icony wrote:
>Hi everyone,
Here's my problem. I have a report that i want to use with the command
openreport. The report open and close in a fraction of a second. I cant
see why i cant view the thing. Cause i can print it and all...

here's my code

Private Sub Command4_Click( )

Dim accObj As Access.Applicat ion
Dim dbs As String

dbs = App.Path & "\bouya.mdb "
Set accObj = GetObject(dbs, "Access.Applica tion")

DoCmd.OpenRepor t "rptbouya1" , acViewPreview
accObj.Visible = True

accObj.Quit
Set accObj = Nothing

End Sub

If someone could help me with this, it would be really appreciated.

Thx in advance
--
jmonty

Jul 28 '06 #2
Thx for the response.
I'm wondering if there is a way to make the user see the report with
just a push of a button in a vba form. The report is already there in
the database.

plz excuse my poor english and my newby questions, i'm just beginning
in both haha.

jmonty wrote:
Although technically it does not (exactly) work this way,
you can think of it in this manner to make some sense of it:
Access VBA does not wait for the prior command/line of code to be completed
before executing the next line.
It is only doing what you told it to do.
It begins to open your report and then you immediately tell it to close the
application.
Try commenting out the line using an apostrophe:

' accObj.Quit

I believe this command is the culprit.

icony wrote:
Hi everyone,
Here's my problem. I have a report that i want to use with the command
openreport. The report open and close in a fraction of a second. I cant
see why i cant view the thing. Cause i can print it and all...

here's my code

Private Sub Command4_Click( )

Dim accObj As Access.Applicat ion
Dim dbs As String

dbs = App.Path & "\bouya.mdb "
Set accObj = GetObject(dbs, "Access.Applica tion")

DoCmd.OpenRepor t "rptbouya1" , acViewPreview
accObj.Visible = True

accObj.Quit
Set accObj = Nothing

End Sub

If someone could help me with this, it would be really appreciated.

Thx in advance

--
jmonty
Aug 1 '06 #3
If it is just a simple thing like opening a report, you do not have to know
how to write VBA code.
Just add a new command button to the form in design mode, and use the Wizard
this time.
Under Categories, select Report Operations and under Actions, select Preview
Report, Click Next.
Select the report from the list and click Next. Select a caption or a picture
and click Finish.
Access will write all the VBA code for you.
Then delete the old button.

jmonty

icony wrote:
>Thx for the response.
I'm wondering if there is a way to make the user see the report with
just a push of a button in a vba form. The report is already there in
the database.

plz excuse my poor english and my newby questions, i'm just beginning
in both haha.
>Although technically it does not (exactly) work this way,
you can think of it in this manner to make some sense of it:
[quoted text clipped - 35 lines]
>
Thx in advance
--
jmonty

Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200608/1

Aug 1 '06 #4
Thx again jmonty.

What i am trying to do is a whole program ( a .exe) that imports excel
sheets, put the data in tables. Then i do request with those table,
etc. What i would like to do is, with my little vb form, be able to :

have one button that transform excel sheets in the right format ( done
)
have one button that imports the excel sheets in a db ( done )
have 2 comboboxs with choices from tables ( done )
have one button to view a report ( ???? )
have one button to print the report ( done )

I dont even have a form in my database. So is it possible to do this
without using the wizard in access ?
I'm thinking maybe there's a "wait" command in vb or maybe i could give
the user control over the report... I just cant think of anything else.
Thx in advance

Alex

Aug 1 '06 #5
I guess I am not understanding.
Is this a VB project created in Visual Studio with an Access backend?,
Or is this VBA code in an Access database?
If it is the latter, I am not understanding why you couldn't use the wizard.
I mean the code can be written by hand if it is not...I mean, if you have to..
but why do it if you don't have to?

jmonty

icony wrote:
>Thx again jmonty.

What i am trying to do is a whole program ( a .exe) that imports excel
sheets, put the data in tables. Then i do request with those table,
etc. What i would like to do is, with my little vb form, be able to :

have one button that transform excel sheets in the right format ( done
)
have one button that imports the excel sheets in a db ( done )
have 2 comboboxs with choices from tables ( done )
have one button to view a report ( ???? )
have one button to print the report ( done )

I dont even have a form in my database. So is it possible to do this
without using the wizard in access ?
I'm thinking maybe there's a "wait" command in vb or maybe i could give
the user control over the report... I just cant think of anything else.

Thx in advance

Alex
--
jmonty

Message posted via http://www.accessmonster.com

Aug 1 '06 #6
yeah it is a vb6 project.
>From what i understand, with vb you can pretty much do whatever you
want with applications. So, i'm opening excel, doing all sort of stuff
with it, etc.
sample of my code :

....

Cells(1, 1).Select
Rows(Selection. Row).Insert shift:=xlUp
Cells(1, 1).Select
ActiveCell.Valu e = "Unité Administrative"
Cells(1, 2).Select
ActiveCell.Valu e = "Poste de travail"
....

Then i'm opening access, the program imports both my excel sheets that
have been saved prior to this. Then, with slq text, i make 3-4 requests
with the tables created with the import of the excel sheets. something
like this :

....
slqtext = "TRANSFORM Count([installs].[Poste de travail]) AS
[CompteDePoste de travail] SELECT [installs].[Unité Administrative]
>From installs, total, uachoisi Where ((([installs].[Unité
Administrative]) Like [uachoisi]![uachoisi])) GROUP BY
[installs].[Unité Administrative] PIVOT total.total;"

'on crée la requete
For Each qry In CurrentDb.Query Defs
If qry.Name = "totalparti el" Then
CurrentDb.Query Defs.Delete ("totalpartiel" )
End If
Next
Set req = CurrentDb.Creat eQueryDef("tota lpartiel", slqtext)
....

its all working very well. I know its not pretty but it still works
fine.

In the database that i'm using via my vb program. I have a report that
i need the user to see. I want the user to be able to click on a button
in the vb form of my .exe and see the report. So the button would do
something like this:

....
open access
open report in view mode
ask the user to close when finished viewing or something
<---------possible or no ?
ask for print ( optional )
quit access
....

Its possible to have a sub that prints the report, but to view it, the
sub would have to kinda "stop" if you see what i mean. That's where i
dont know what to do.
I'm thinking i could copy/paste the code generated with the creation of
the button in a form in access maybe, i dont know.

I hope i made myself clearer. I know i'm not good in expressing myself
uin english.

Thx in advance

Alex

Aug 1 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2951
by: Gerry Laenen | last post by:
Hi all, As the subject says, serious troubles over here. I hope some of you can help me out. I am using VB6, CR9, ADO 2.8 and SQL Server 2000. I have an ActiveX DLL (VB6) which has a method that returns a Crystal Reports Report (CRAXDRT.Report). This main report consists of several Subreportobjects. In this method, I open the recordsets and bind them each subreport. Because the recordsets need to stay open, I put each recordset object...
4
7051
by: deko | last post by:
I can't move a multi-page report to the last record unless I keep the popup form (that defined it's subreports) open. DoCmd.OpenReport "rptStandard", acViewNormal DoCmd.Close acForm, "frmReportOptions" <== popup form This is the error I get when I try to move to the last page of the report *after* closing the popup: "This expression is typed incorectly, or is too complex to be evaluate...."
1
17664
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to Create a Dynamic Crosstab Report PRODUCT :Microsoft Access PROD/VER:1.00 1.10 OPER/SYS:WINDOWS
2
1641
by: Denise | last post by:
How do I get the report to not spend time pulling up the data when I'm going to bail out of the report anyway? Below is the code in my report. I first show the user a form where they can select some filtering parameters which I put in Getz's TaggedValues class. But they can hit a Cancel button if they decide they don't want any report. When I test the Cancel button I'd like the report to close immediately but it seems to spend some...
1
3496
by: Red Hammer | last post by:
Hi, I have a report that I used the data designer to create and what happens is that it does not update until the application is closed and opened again. For example, you can enter a new record and then open the report and it will not show the new record until the application is closed and started up again. Anybody got any ideas how I can make the report update immediately? Thanks for any help you can give. Weblog:...
13
3911
by: salad | last post by:
Hi Guys: I was stuck. I needed to send a report to a file. My beautiful report(s) in Access were going to require loss of formatting with RTFs, a PITA in WordMailMerge, sending it as a text file...whatever. I described my situation to the guy I'm doing work for and he did some research for me and came up with the following link. http://www.novapdf.com/ The part that should excite us Access developers is their SDK
3
2676
by: Asaf | last post by:
Hi, We have a VB6 application that needs to use a new control written in ..NET v1.1 C#, imported as a COM control. We have tried adding the C# control to the VB6 control both dynamically (using Controls.Add) and using the VB6 designer. In both approaches the behavior was identical: the control was functional and accessible, but the application crashed on exit with the message <app name> "has encountered a problem and needs to close. We...
0
860
by: Alexeye2008 | last post by:
I am working on Access report from vb6 form. I am now able to open the report in maximized window. But still users can go to database window, etc which I don’t want. Can any one help me in providing clue for this if clause code IF (…needed…!) acc.Quit db.Close Set acc = Nothing Set db = Nothing
21
1792
by: Galen Somerville | last post by:
My application receives and displays Heart sounds and ECG's in real time. This data comes from a proprietary USB 2.0 device. Unlike most USB devices, this data comes in short bursts of about 24 bytes. These bursts could come as fast as every millisecond. The display of the sound and ECG traces is similar to an oscilloscope display except a blank space of about 5 pixels is shown as it sweeps across the screen. This means that not only is...
0
8610
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8545
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9090
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8810
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8810
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7633
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4562
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2978
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2242
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.