05. juli 2002 - 11:49
Der er
26 kommentarer og 1 løsning
Udskriv Access Rapport Direkte fra VB 6.0
Hejsa... jeg snuppede den lille kode fra en der kunne udskrive en Access rapport fra VB 6.0... Private Sub Command3_Click() Dim ac As Access.Application Set ac = New Access.Application ac.OpenCurrentDatabase "i:\bredan intranet\filer\Produkt Databse\Produkt Database til VB.MDB" ac.DoCmd.OpenReport "Wärtsilä Forespørgelse\", acViewNormal ac.CloseCurrentDatabase End Sub Men den melder fejl i den anden linie: Dim ac As Access.Application hvorfor..... kan man ikke sætte det hele til en knap???? MvH Kim
Annonceindlæg tema
Cloud & AI
I dette særtema ser vi på, hvordan cloud og AI bliver fundamentet for virksomhedernes digitale forretning, og hvordan de nye muligheder for automatisering og forretningsværdi kan udnyttes uden at miste overblik, sikkerhed og menneskelig kontrol.
Tror du ikke du skulle afsætte lidt points ? :o)
You have to have a reference to Access!
Ok...... jeg gir 15 point så.... sorry
before you can automate Access you have to have a referecne to Access. This is done in the tools + references menu while in Code View!
an ac.visible will help too or youw ont see it
05. juli 2002 - 12:50
#10
Ok terry.. If you help me with this one you will get all the points....ok???
05. juli 2002 - 12:55
#11
Terry... you know that i'm not that great to program codes and so on.... so could you please take it step by step??
05. juli 2002 - 13:01
#12
Dim acc As Object Set acc = CreateObject("Access.Application") acc.OpenCurrentDatabase "i:\bredan intranet\filer\Produkt Databse\Produkt Database til VB.MDB" acc.Visible = False acc.DoCmd.OpenReport "Wärtsilä Forespørgelse\", , acViewNormal acc.Quit
05. juli 2002 - 13:03
#13
BUT You STILL MUST have a reference to Access! If Access IS NOT installed then you CAN NOT automate Access. DO YOU UNDERSTAND THIS??????
05. juli 2002 - 13:18
#14
Thanks terry..... but when i pick the menu tools, when the menu is in code view, theres is no meny called references.... And that code you wrote... where shall I put that?? On the cmdbutton, or what???
05. juli 2002 - 13:22
#15
Sorry! Project + references
05. juli 2002 - 13:23
#16
yes place the code in a button
05. juli 2002 - 13:33
#17
Okay.... it works......!!!! Can you stop the printing, and just open the report, so you can choose the page you wanna print??? Or choose it in VB 6.0???
05. juli 2002 - 13:52
#18
acc.Visible = True acc.DoCmd.OpenReport "Wärtsilä Forespørgelse\", acViewPreview You will have to remove acc.quit or Access will close!
05. juli 2002 - 13:54
#19
Thanx......
05. juli 2002 - 13:57
#20
But.... the report still just print..... AND access closes..... Here is my code: Private Sub Command3_Click() Dim acc As Object Set acc = CreateObject("Access.Application") acc.OpenCurrentDatabase "i:\bredan intranet\filer\Produkt Databse\Produkt Database til VB.MDB" acc.Visible = True acc.DoCmd.OpenReport "1", , acPreviewNormal End Sub
05. juli 2002 - 14:02
#21
acc.DoCmd.OpenReport "1", acPreviewNormal Do you have a report named "1" does it close now?
05. juli 2002 - 14:15
#22
Yes it's just a test report.... And yes it still closes.... Here is my new code from you: Private Sub Command3_Click() Dim acc As Object Set acc = CreateObject("Access.Application") acc.OpenCurrentDatabase "i:\bredan intranet\filer\Produkt Databse\Produkt Database til VB.MDB" acc.Visible = True acc.DoCmd.OpenReport "1", acPreviewNormal End Sub
05. juli 2002 - 14:22
#23
if you sent the project+dB to terrysanthell.dk then I will see if I can see what is wrong
05. juli 2002 - 14:23
#24
terry@santhell.dk
05. juli 2002 - 15:06
#25
acc.DoCmd.OpenReport "1", acViewPreview
05. juli 2002 - 15:13
#26
Aaaaaand it WORKS!!!!!!!!! YES... Thank you very much Terry!!!
05. juli 2002 - 19:49
#27
Gggrrreeeaaaaatt!!! :o)
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser