473,508 Members | 2,212 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.Application
Dim dbs As String

dbs = App.Path & "\bouya.mdb"
Set accObj = GetObject(dbs, "Access.Application")
DoCmd.OpenReport "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 4313
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.Application
Dim dbs As String

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

DoCmd.OpenReport "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.Application
Dim dbs As String

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

DoCmd.OpenReport "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.com
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.Value = "Unité Administrative"
Cells(1, 2).Select
ActiveCell.Value = "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.QueryDefs
If qry.Name = "totalpartiel" Then
CurrentDb.QueryDefs.Delete ("totalpartiel")
End If
Next
Set req = CurrentDb.CreateQueryDef("totalpartiel", 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
2946
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...
4
7032
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,...
1
17632
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...
2
1634
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...
1
3491
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...
13
3872
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...
3
2667
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...
0
853
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...
21
1766
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...
0
7227
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,...
0
7331
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,...
1
7054
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...
0
7501
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...
1
5056
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1564
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 ...
1
768
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
424
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.