A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

VBA: test for empty recordset; use of assistant baloon object



 
 
Thread Tools Display Modes
  #1  
Old May 1st, 2008, 12:03 AM posted to microsoft.public.access.forms
Clif McIrvin[_2_]
external usenet poster
 
Posts: 629
Default VBA: test for empty recordset; use of assistant baloon object

Hello again g.

This time I'm looking for comments / suggestions as to whether I'm on
the right track or not. The code sample below is doing what I expect it
to, I'm just wondering about my coding technique.

Actually, I have at least three questions:

1 and 2. The code was working fine until I stumbled into an attempt to
exit the Remarks control with an empty recordset which threw an object
not defined error on the 'If Me.Box.Value ' line. Is my solution of
testing 'me.recordset.bof' valid from both coding style and Access / Jet
usage?

3. My use of the assistant balloon object appears to be working as I
expect; but as I was unable to find any documentation of this particular
technique I'm wondering if I'm setting myself up for future trouble.

Comments, anyone?

The form in question is actually a sub-form but I also sometimes use it
as a stand-alone form. The controls are bound; Remarks is Text and Box
is Boolean. My environment is XP Pro SP2, Access 2003 SP3 w/Hotfix using
DAO 3.6.

Begin Code Sample=============

Option Compare Database

Public myBalloon As Balloon

Private Sub Form_Load()
With Assistant
.On = True
.Visible = False
End With

Set myBalloon = Assistant.NewBalloon
myBalloon.Close
End Sub

Private Sub Form_Unload(Cancel As Integer)
Set myBalloon = Nothing
With Assistant
.Visible = False
.On = False
End With
End Sub

Private Sub Remarks_Enter()
If Me.Recordset.BOF Then 'skip all if empty recordset
ElseIf Me.Box.Value = True Then
With myBalloon
.Text = Me!Remarks.StatusBarText
.Mode = msoModeModeless
.Button = msoButtonSetNone
.Show
End With
End If
End Sub

Private Sub Remarks_Exit(Cancel As Integer)
If Me.Recordset.BOF Then 'skip all if empty recordset
ElseIf Me.Box.Value = True Then
myBalloon.Close
End If
End Sub

End Code Sample===============


--
Clif
Still learning Access 2003




  #2  
Old May 1st, 2008, 01:58 AM posted to microsoft.public.access.forms
Arvin Meyer [MVP]
external usenet poster
 
Posts: 4,231
Default test for empty recordset; use of assistant baloon object

Try this:

With Me.RecordsetClone
If Not (.EOF And .BOF) Then
With myBalloon
' yada yada
End With
End If
End With

"Clif McIrvin" wrote in message
...
Hello again g.

This time I'm looking for comments / suggestions as to whether I'm on the
right track or not. The code sample below is doing what I expect it to,
I'm just wondering about my coding technique.

Actually, I have at least three questions:

1 and 2. The code was working fine until I stumbled into an attempt to
exit the Remarks control with an empty recordset which threw an object not
defined error on the 'If Me.Box.Value ' line. Is my solution of testing
'me.recordset.bof' valid from both coding style and Access / Jet usage?

3. My use of the assistant balloon object appears to be working as I
expect; but as I was unable to find any documentation of this particular
technique I'm wondering if I'm setting myself up for future trouble.

Comments, anyone?

The form in question is actually a sub-form but I also sometimes use it as
a stand-alone form. The controls are bound; Remarks is Text and Box is
Boolean. My environment is XP Pro SP2, Access 2003 SP3 w/Hotfix using DAO
3.6.

Begin Code Sample=============

Option Compare Database

Public myBalloon As Balloon

Private Sub Form_Load()
With Assistant
.On = True
.Visible = False
End With

Set myBalloon = Assistant.NewBalloon
myBalloon.Close
End Sub

Private Sub Form_Unload(Cancel As Integer)
Set myBalloon = Nothing
With Assistant
.Visible = False
.On = False
End With
End Sub

Private Sub Remarks_Enter()
If Me.Recordset.BOF Then 'skip all if empty recordset
ElseIf Me.Box.Value = True Then
With myBalloon
.Text = Me!Remarks.StatusBarText
.Mode = msoModeModeless
.Button = msoButtonSetNone
.Show
End With
End If
End Sub

Private Sub Remarks_Exit(Cancel As Integer)
If Me.Recordset.BOF Then 'skip all if empty recordset
ElseIf Me.Box.Value = True Then
myBalloon.Close
End If
End Sub

End Code Sample===============


--
Clif
Still learning Access 2003






  #3  
Old May 2nd, 2008, 12:27 AM posted to microsoft.public.access.forms
Clif McIrvin[_2_]
external usenet poster
 
Posts: 629
Default test for empty recordset; use of assistant baloon object

"Arvin Meyer [MVP]" wrote in message
...
Try this:

With Me.RecordsetClone
If Not (.EOF And .BOF) Then
With myBalloon
' yada yada
End With
End If
End With


Thanks, Arvin.

I see the improvement to the self-documentation here as well as the more
particular test.

--
Clif
Still learning Access 2003




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:34 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.