How do i hide the access application and show only form

A

Asty

hi all,
I am new to this community.please help me with this.
i am working with Access from visual basic 6.0.
i have created a form in access to get the user input.
i have other forms of visual basic that are independent of access.
How can i load the form that is in the access with out showing the MS Access
application.
thanks
 
M

microb0x

One thing to make note of when implementing that solution. Your
form(s) must have the Popup setting as True in the 'Other' tab of the
forms properties.
 
A

Arvin Meyer [MVP]

As you suggested, the popup property must be set to True. One other thing.
Make absolutely sure that there is good error handling in every procedure,
and that no macros are used anywhere (because there is no error handling in
macros). If there isn't good error handling, and the code breaks, the
computer may need rebooting because you can't get to the Access UI.
 
A

Asty

hi
when i run the program it is asking to select a data source.i could not
understand if i need to select the driver. please be a litlle detail.
thanks
 
A

Asty

I have some problem here. when i run the program it is asking to select a
Data source. Possibly it is asking for the driver. : i am just putting my
code here:
In form module i have a code like this: please help me with this . and
please be a little patient for my queries..

Thanks alot..
here is the code:

Dim acc As Access.Application
Dim db As DAO.Database
Dim strDbName As String
Const SW_HIDE As Integer = 0




Private Sub Command1_Click()
On Error GoTo ErrorHandler

Set acc = New Access.Application
Set db = acc.DBEngine.OpenDatabase(strDbName, False, False)
strDbName = "E:\with db\erxp\Copy of dbfiletype.mdb"
acc.OpenCurrentDatabase strDbName
acc.DoCmd.OpenForm "test"
cmd1_Click_exit:
Set db = Nothing
Exit Sub
'WIN API Function to hide the access application


fSetAccessWindow (SW_HIDE)

ErrorHandler:
If Err.Number <> 0 Then

' Handle errors
MsgBox "An unexpected error has occurred." & _
vbCrLf & "Please note of the following details:" & _
vbCrLf & "Error Number: " & Err.Number & _
vbCrLf & "Description: " & Err.Description _
, vbCritical, "Error"
Resume cmd1_Click_exit
End If
End Sub



Under the standard module :

Private Declare Function apiShowWindow Lib "user32" _
Alias "ShowWindow" (ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long
Public Function fSetAccessWindow(nCmdShow As Long)
'Usage Examples
'Maximize window:
' ?fSetAccessWindow(SW_SHOWMAXIMIZED)
'Minimize window:
' ?fSetAccessWindow(SW_SHOWMINIMIZED)
'Hide window:
' ?fSetAccessWindow(SW_HIDE)
'Normal window:
' ?fSetAccessWindow(SW_SHOWNORMAL)
'
Dim loX As Long
Dim loForm As Form
On Error Resume Next
Set loForm = Screen.ActiveForm
If Err <> 0 Then 'no Activeform
If nCmdShow = SW_HIDE Then
MsgBox "Cannot hide Access unless " _
& "a form is on screen"
Else
loX = apiShowWindow(hWndAccessApp, nCmdShow)
Err.Clear
End If
Else
If nCmdShow = SW_SHOWMINIMIZED And loForm.Modal = True Then
MsgBox "Cannot minimize Access with " _
& (loForm.Caption + " ") _
& "form on screen"
ElseIf nCmdShow = SW_HIDE And loForm.PopUp <> True Then
MsgBox "Cannot hide Access with " _
& (loForm.Caption + " ") _
& "form on screen"
Else
loX = apiShowWindow(hWndAccessApp, nCmdShow)
End If
End If
fSetAccessWindow = (loX <> 0)
End Function
--
Asty


Arvin Meyer said:
As you suggested, the popup property must be set to True. One other thing.
Make absolutely sure that there is good error handling in every procedure,
and that no macros are used anywhere (because there is no error handling in
macros). If there isn't good error handling, and the code breaks, the
computer may need rebooting because you can't get to the Access UI.
 
L

Larry Linson

Asty said:
I am new to this community.please help me with this.
i am working with Access from visual basic 6.0.
i have created a form in access to get the user input.
i have other forms of visual basic that are independent of access.
How can i load the form that is in the access with out showing the MS
Access
application.
thanks

If I understand, you'd like to use the Access form from the separate Visual
Basic product. You can't do that without opening Access via COM Automation,
as others have indicated. Why not create a VB form to interact with the Jet
(not Access, although it is sometimes so called) database you are using? You
can do data-bound VB Forms using the Data Control, though they don't always
work quite as smoothly as bound Forms in Access or you can do unbound Forms
with DAO or ADO code to access the database.

Larry Linson
Microsoft Access MVP
 
S

s4

Hi,
I've tried the code, and I've also set my switchboard to me.visible = true
in vba on open. I've put that code in as a module and then called it in the
form's onopen event. It just won't hide Access. If I set the Pop-up property
wrong it gives me a messagebox saying "Cannot hide Access...", but when
everything is right just nothing happens. I'm using Access 2002. Any
suggestions?
Thanks
 
A

Albert D. Kallal

s4 said:
Hi,
I've tried the code, and I've also set my switchboard to me.visible = true
in vba on open. I've put that code in as a module and then called it in
the
form's onopen event. It just won't hide Access. If I set the Pop-up
property
wrong it gives me a messagebox saying "Cannot hide Access...", but when
everything is right just nothing happens. I'm using Access 2002. Any
suggestions?
Thanks

You most certainly can, and should hide all of the ms-access interface. The
options to complete hide and keep people out of the ms-access interface can
easily be done using the tools->start-up options. Using those options allows
you to complete hide the ms-access interface (tool bars, database window
etc). Also, using these options means you
do not have to bother setting up security.

Try downloading and running the 3rd example at my following web site that
shows a hidden ms-access interface, and NO CODE is required to do
this....but just some settings in the start-up.

Check out:

http://www.members.shaw.ca/AlbertKallal/msaccess/DownLoad.htm

After you try the application, you can exit, and then re-load the
application, but hold down the shift key to by-pass the start-up options. If
want, you can even disable the shift key by pass. I have a sample mdb file
that will let you "set" the shift key bypass on any application you want.
You can get this at:
http://www.members.shaw.ca/AlbertKallal/msaccess/msaccess.html
 

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