Access-to-Access Automation

B

Bob Barnes

The code below ran in VB6 and the called Access DB was NOT visible.

We've transferred the code to another Access DB..the code works fine, but
the called Access DB is visible.

These are Public varaiables..
gnMcnCopies, gDailyRep, gDateSel, gShiftSel, gIDGroup & gIIDProc

Tips?? TIA - Bob

Private Sub GoPrint()
Dim MainDB As Access.Application
On Error GoTo AAA1
Screen.MousePointer = 11
Set MainDB = CreateObject("Access.Application.11")
txtCopies = gnMcnCopies
Select Case gDailyRep
Case "0", "N/A"
'No report to print
MsgBox "There is no report for this Group/Process."
Case Else
lbl275.Visible = True: txtCopies.Visible = True: Me.Repaint
End Select
With MainDB
.OpenCurrentDatabase ("C:\BobDev\pas3dot2.mdb")
.Visible = False
.DoCmd.OpenForm "VB-to-Acc Rpts"
.Forms![VB-to-Acc Rpts]!txtProdDate = gDateSel
.Forms![VB-to-Acc Rpts]!txtPartsDate = gDateSel
.Forms![VB-to-Acc Rpts]!txtProdShift = gShiftSel
.Forms![VB-to-Acc Rpts]!txtGroupID = gIDGroup
.Forms![VB-to-Acc Rpts]!txtProcessID = gIIDProc
.Forms![VB-to-Acc Rpts]!cmdSetGlobalVariables.SetFocus
If txtCopies = 1 Then
.DoCmd.OpenReport (gDailyRep)
txtCopies = 0: Me.Repaint
ElseIf txtCopies = 2 Then
.DoCmd.OpenReport (gDailyRep)
txtCopies = 1: Me.Repaint
.DoCmd.OpenReport (gDailyRep)
txtCopies = 0: Me.Repaint
ElseIf txtCopies = 3 Then
.DoCmd.OpenReport (gDailyRep)
txtCopies = 2: Me.Repaint
.DoCmd.OpenReport (gDailyRep)
txtCopies = 1: Me.Repaint
.DoCmd.OpenReport (gDailyRep)
txtCopies = 0: Me.Repaint
End If
lbl275.Visible = False: txtCopies.Visible = False
.Visible = False
.CloseCurrentDatabase
.Quit: Set MainDB = Nothing
End With
AAA2:
Screen.MousePointer = 1: Exit Sub
AAA1:
Select Case Err
Case 2501
Resume AAA2
Case Else
MsgBox Err.Number & " " & Err.Description
Resume
GoTo AAA2
End Select
End Sub
 
A

Albert D. Kallal

Bob Barnes said:
Set MainDB = CreateObject("Access.Application.11")

MainDB.visible = false

Try adding the above line of code.....

Also, note that the access runtime can NOT be automated, only the full
versions....
 
B

Bob Barnes

Albert..I tried..snippet below..it didn't work - other ideas please..thank
you - bob

Set MainDB = CreateObject("Access.Application.11")
MainDB.Visible = False
txtCopies = gnMcnCopies
Select Case gDailyRep
Case "0", "N/A"
'No report to print
MsgBox "There is no report for this Group/Process."
Case Else
lbl275.Visible = True: txtCopies.Visible = True: Me.Repaint
End Select
With MainDB
.OpenCurrentDatabase ("C:\BobDev\pas3dot2.mdb")
'.Visible = False
.DoCmd.OpenForm "VB-to-Acc Rpts"
'.Forms![VB-to-Acc Rpts].Visible = False
.Forms![VB-to-Acc Rpts]!txtProdDate = gDateSel
 
A

Albert D. Kallal

Bob Barnes said:
Albert..I tried..snippet below..it didn't work - other ideas please..thank
you - bob


That is really strange..

By default it if you don't set the visibility of the application you launch,
then you should not see the running a copy of MS access at all (and it seems
that your prior experience supports this type of behavior). I came along and
suggested setting the visible=false, but in fact you should not have to do
that.

I would check the "startup code" of the application that you're automating
(launching). Perhaps in its startup code it has some code that sets the
application visible=true?

I would suggest that if the application you're launching has any startup
forms, I would suggest you remove that because you can't really be sure if
the startup code has finished when you start to use doCmd etc. in this
running instance. So, perahps you make a separate database with linked
tables to the actual data tables you need without any startup forms. (and if
you don't have any startup forms in this application, then I'm perplexed as
to why the visibility issues coming into play).

I'm not really sure what your problem is in this case, since as you
previously noted the application as a normal general rule does not display
and you did not have to play with setting visible=false.

About the only suggestion I have at this time is to check if any startup
forms/code in the application you launch.....
 
B

Bob Barnes

About the only suggestion I have at this time is to check if any startup
forms/code in the application you launch.....

There is a Startup Form, but it never displayed before...possibly because
the VB6 Form calling it was "in front of it".

The automation App functions properly..all Users will just know the brief
appearance of the Startup Form of the automated Access DB shows it's doing
its job.

Any other ideas...you're always very helpful Albert - thank you - Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top