Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / ActiveX Controls / August 2005

Tip: Looking for answers? Try searching our database.

How to make a log window from VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Helge V. Larsen - 05 Aug 2005 16:38 GMT
I am developing an Access application where I am controlling a lot of
activity from VBA.
I would like to present a 'window' or form to the user that shows the
progress.
That is, I would like to be able to open a 'window', show some text, and (as
time goes by)
write some more lines at the bottom of the 'window'.
I would prefer not to have to let VBA send the text to a database table that
is referenced by the 'window',
but instead have VBA put the text directly into the 'window'.

How can I do this ?
Ron Weiner - 05 Aug 2005 16:45 GMT
Helge

If you had a form named frmLog that contained a unbound Text box txtLog then
as long as frmLog is loaded from anywhere in the app

Forms!frmLog.txtLog.value = Forms!frmLog.txtLog.value  & "New text you want
to add." & vbcrlf

will append text to the text box.

Ron W
www.WorksRite.com

> I am developing an Access application where I am controlling a lot of
> activity from VBA.
[quoted text clipped - 8 lines]
>
> How can I do this ?
Dirk Goldgar - 05 Aug 2005 16:54 GMT
> Helge
>
[quoted text clipped - 5 lines]
>
> will append text to the text box.

That's what I would do, too.  I have a feeling you may have to do some
tweaking to make the text box scroll to the last item entered, once the
displayable area has been filled.  You may have to set the focus to the
text box as part of that process, and I'm not sure you want to do that.
Of course, you could prepend the newest lines to the beginning of the
text box, instead of adding them at the end, but that might be
confusing.

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Karl E. Peterson - 05 Aug 2005 18:00 GMT
>> Helge
>>
[quoted text clipped - 9 lines]
> tweaking to make the text box scroll to the last item entered, once
> the displayable area has been filled.

The trick is something like this:

 txtLog.SelLength = 0
 txtLog.SelStart = Len(txtLog.Text)
 txtLog.SelText = NewTextString

That automatically scrolls to, and appends to, the end of whatever's already there.

Later...   Karl
Signature

Working Without a .NET?
http://classicvb.org/petition

Ron Weiner - 05 Aug 2005 18:38 GMT
Yea - But Access aint VB.

In access before you can touch any of those text box properties you first
have to set focus to the text box so.....

txtLog.setFocus
txtLog.SelLength = 0
txtLog.SelStart = Len(txtLog.Text)
txtLog.SelText = "New text you want to add." & vbcrlf
' Optionally set the focus back to somewhere else

Ron W
www.WorksRite.com

> >> Helge
> >>
[quoted text clipped - 19 lines]
>
> Later...   Karl
Karl E. Peterson - 05 Aug 2005 20:53 GMT
> Yea - But Access aint VB.

Oh Yeah? <g>

> In access before you can touch any of those text box properties you
> first have to set focus to the text box so.....
>
> txtLog.setFocus

Okay, whatever...  "Some code left to the reader..." <bg>

Thanks...   Karl
Signature

Working Without a .NET?
http://classicvb.org/petition

Ron Weiner - 05 Aug 2005 18:44 GMT
Ooooppppsssss....

Actually

Forms!frmLog.txtLog.setFocus
Forms!frmLog.txtLog.SelLength = 0
Forms!frmLog.txtLog.SelStart = Len(txtLog.Text)
Forms!frmLog.txtLog.SelText = "New text you want to add." & vbcrlf

Ron W
www.WorksRite.com

> >> Helge
> >>
[quoted text clipped - 19 lines]
>
> Later...   Karl
Dirk Goldgar - 05 Aug 2005 18:54 GMT
>> That's what I would do, too.  I have a feeling you may have to do
>> some tweaking to make the text box scroll to the last item entered,
[quoted text clipped - 8 lines]
> That automatically scrolls to, and appends to, the end of whatever's
> already there.

That'll work, so long as the text box has the focus on that form.  If
not, you can't reference the .Text  or .Sel... properties.  I was
interested to discover, though, that the text box doesn't have to have
the application's focus, just the form's focus.  That means my worry
about setting focus to the log form was unnecessary.  This version works
fine for me:

   With Forms!frmLog!txtLog
       .Value = (.Value + vbCrLf) & Time & " " & strMessage
       .SetFocus
       .SelStart = Len(.Text)
   End With

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.