By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,477 Members | 1,641 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,477 IT Pros & Developers. It's quick & easy.

vb6: report open and close way too fast

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.