Window behaviour

Window behaviour

Anonymous
Not applicable
212 Views
2 Replies
Message 1 of 3

Window behaviour

Anonymous
Not applicable
I created a small utility which ran a query on an Access database. When I first ran it (on Windows 95)only a small dialogue box appeared requesting the user to enter criteria.(Access stayed minimised) When we upgraded to Windows NT and now 2000, Access pops up in front of Autocad followed by the dialogue box. ~ It doesn't stop the form from working but it's not as neat as I would like it. Can anyone explain why this change should have happened without any change in the code ? Should teh code be amended in any way ?~ I've posted the code below. I'm a relative newcomer and completely self taught so forgive me if my code is untidy and contains any useless baggage. *****Code starts here****

Private Sub Getinfo_Click()
InfoBase = "P:\Gore\material.mdb"
Set Access = New Access.Application
Access.OpenCurrentDatabase InfoBase
Access.Application.Visible = True
On Error Resume Next
Access.DoCmd.OpenQuery "Mat1", , acReadOnly
Access.DoCmd.GoToRecord acDataQuery, "Mat1", acGoTo, 1
Access.DoCmd.DoMenuItem acFormBar, acEditMenu, acSelectRecord, , acMenuVer70
Access.DoCmd.DoMenuItem acFormBar, acEditMenu, acCopy, , acMenuVer70
Access.DoCmd.Close acQuery, "mat1", acSaveNo
Access.CloseCurrentDatabase
Set Access = Nothing
Infotext.SetFocus
Infotext.Paste
End Sub
*****Code ends here*****
~ Hendie
0 Likes
213 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Hi Hendie,
The quick fix is just to eliminate one line of code in your sub. remove
or comment out the line:
Access.Application.Visible = True

This should stop Access from popping up on your screen. But in addition
you may want to look into using dao or ado to retrieve info from the
database. If you decide to do so, ado is the up and coming while dao is
on it's way out. So if you have to learn it, ado is probably the better
choice. This will allow you to read or write to the database even if
Access is not installed on your machine. To use one or the other, just
check the box under tools, references. All the new methods will appear
in your object browser and the help files have samples. There are also
quite a few of us on this ng who write in ado or dao if you have questions.
-Josh

hendie wrote:

> I created a small utility which ran a query on an Access database. When
> I first ran it (on Windows 95)only a small dialogue box appeared
> requesting the user to enter criteria.(Access stayed minimised) When we
> upgraded to Windows NT and now 2000, Access pops up in front of Autocad
> followed by the dialogue box. ~ It doesn't stop the form from working
> but it's not as neat as I would like it. Can anyone explain why this
> change should have happened without any change in the code ? Should teh
> code be amended in any way ?~ I've posted the code below. I'm a relative
> newcomer and completely self taught so forgive me if my code is untidy
> and contains any useless baggage. *****Code starts here****
>
> Private Sub Getinfo_Click()
> InfoBase = "P:\Gore\material.mdb"
> Set Access = New Access.Application
> Access.OpenCurrentDatabase InfoBase
> Access.Application.Visible = True
> On Error Resume Next
> Access.DoCmd.OpenQuery "Mat1", , acReadOnly
> Access.DoCmd.GoToRecord acDataQuery, "Mat1", acGoTo, 1
> Access.DoCmd.DoMenuItem acFormBar, acEditMenu, acSelectRecord, ,
> acMenuVer70
> Access.DoCmd.DoMenuItem acFormBar, acEditMenu, acCopy, , acMenuVer70
> Access.DoCmd.Close acQuery, "mat1", acSaveNo
> Access.CloseCurrentDatabase
> Set Access = Nothing
> Infotext.SetFocus
> Infotext.Paste
> End Sub
>
> * ****Code ends here***** ~ Hendie
0 Likes
Message 3 of 3

Anonymous
Not applicable
It is not good way to retrieve little piece of
information by lauching an Access application, having Access run a query, copy
it to Windows clipboard, quiting Access and finally pasting the data oo your
small utitly's form. Not only its slow speed of this tedius procedure (only
having Avccess started will take anywhere between 5 to 20 seconds) is undesired,
but also it needs Access being installed on the computer, which uses your
untitly.

 

Use either DAO or ADO to access data in an Access
database. In your case, only a fraction of second is enough to retrieve the data
you need, and you do not actually need to install Access on the computer as long
as the .mdb file is accessible.

 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I
created a small utility which ran a query on an Access database. When I first
ran it (on Windows 95)only a small dialogue box appeared requesting the user
to enter criteria.(Access stayed minimised) When we upgraded to Windows NT and
now 2000, Access pops up in front of Autocad followed by the dialogue box. ~
It doesn't stop the form from working but it's not as neat as I would like it.
Can anyone explain why this change should have happened without any change in
the code ? Should teh code be amended in any way ?~ I've posted the code
below. I'm a relative newcomer and completely self taught so forgive me if my
code is untidy and contains any useless baggage. *****Code starts here****

Private Sub Getinfo_Click()
    InfoBase =
"P:\Gore\material.mdb"
    Set Access = New
Access.Application
    Access.OpenCurrentDatabase
InfoBase
    Access.Application.Visible = True

    On Error Resume Next

    Access.DoCmd.OpenQuery "Mat1", , acReadOnly

    Access.DoCmd.GoToRecord acDataQuery, "Mat1",
acGoTo, 1
    Access.DoCmd.DoMenuItem acFormBar,
acEditMenu, acSelectRecord, , acMenuVer70

    Access.DoCmd.DoMenuItem acFormBar, acEditMenu,
acCopy, , acMenuVer70
    Access.DoCmd.Close acQuery,
"mat1", acSaveNo
    Access.CloseCurrentDatabase

    Set Access = Nothing

    Infotext.SetFocus

    Infotext.Paste
End Sub

  • ****Code ends here***** ~ Hendie
  • 0 Likes