Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Code for whether or not an OLE object table field has a value?

2 views
Skip to first unread message

mlh, eit

unread,
Dec 24, 2001, 12:25:34 AM12/24/01
to
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I have a button on a form that is not visible.
I want to make it visible when a record becomes
current who's [DoItems].[Pic] field has a Paintbrush
graphic item in it.I plan on using the form's OnCurrent
event property to launch code that will examine
this field's contents.

I tried this: If IsNull(Me!Pic) Then ...
I tried several variations of same.
Nothing worked. Any ideas?
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Turtle

unread,
Dec 24, 2001, 10:20:04 AM12/24/01
to
You're certainly on the right track, you must have just missed some detail.

I did this -
Added an OLE field (MyOLE) to an existing test table.
Put a graphic in one record, but not others.
Created an AutoForm from the table.
Added a checkbox with its controlsource set to:
=isnull([MyOLE])

I could browse through the records; the checkbox correctly showed a
check where there was no entry in the table, and no check where there was a
table.

If this is not enough to get your application straightened out, perhaps
you could post the code that you are using in your OnCurrent event.
I'm also not quite sure of the significance of [DoItems] in your
presentation.

HTH
- Turtle

"mlh, eit" <Shak...@Triad.rr.com> wrote in message
news:nuv6ut8f4svmvrp00...@4ax.com...

mlh, eit

unread,
Dec 24, 2001, 11:03:43 AM12/24/01
to
Thx, Turtle. Will give a try. Intermittent
sessions of brain death result in my
overlooking the obvious from time to
time.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

mlh, eit

unread,
Dec 24, 2001, 4:00:10 PM12/24/01
to
I tried the same thing you said.
That worked for me. However,
in procedure behind OnCurrent
event, it does not. Here's what
I have tried so far:

Sub Form_Current ()
'*****************************************************************
' Added this code 12/24/2001 - long after this form's birth. Its
' purpose is to make a button visible if there is a graphic assoc-
' iated with the current Do-Item record.
'*****************************************************************
'Dim MyContents As Variant
'MyContents = Val(Forms!frmAdminDoListEntryForm!Pic) 'produces
'Invalid use of Null' error
'MyContents = Me![Pic]
'If IsNull(MyContents) Then 'produces
'Object has no value' error if MyContents = Me![Pic]
'If IsNull(Me!Pic) Then 'produces
'Object has no value' error
If IsNull([Pic]) Then 'produces
'Object has no value' error
'If Me!Pic Then 'produces
'Object has no value' error
PictureClicker.Visible = False
Pic.Visible = False
Else
PictureClicker.Visible = True
End If

End Sub

I have tried all the rem'd variations to no avail.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


On Mon, 24 Dec 2001 10:20:04 -0500, "Turtle"
<macde...@mindspring.com> wrote:

Turtle

unread,
Dec 25, 2001, 9:05:25 AM12/25/01
to
It's a little difficult to tell quite what you had un-commented at any time,
but this code worked for me in the same form's OnCurrent event:
MyOLE.visible=not isnull(MyOLE)

HTH
- Turtle

"mlh, eit" <Shak...@Triad.rr.com> wrote in message

news:f0n8utcaadugidl6d...@4ax.com...

mlh, eit

unread,
Dec 30, 2001, 12:59:59 PM12/30/01
to
OK. MyOLE.visible=not isnull(MyOLE) is a wee bit
different from anything I've tried. Lemme give it a go.
Will follow up momentarily. Warmest regards, mlh.
======================================

mlh, eit

unread,
Dec 30, 2001, 1:34:24 PM12/30/01
to
Turtle: per your suggestion, I included a line like
you recommended. (See code below) Still, it yielded
a 2427 error (Object has no value). Oh, what to do?


Sub Form_Current ()
'*****************************************************************
' Purpose is to make a button visible if there is a graphic
' associated with the current Do-Item record.
'*****************************************************************
On Error GoTo Form_Current_Err:
Dim ThisForm As String
ThisForm = Me.Name
PictureClicker.Visible = Not IsNull(Pic)
'(Above line is what Turtle recommended)

Dim WhichRec As Integer
WhichRec = GetFormRecNum(Me)
RecNum.Caption = "#" & Str$(WhichRec)

ExitForm_Current:
Exit Sub

Form_Current_Err:
Dim r As String, k As String, Message3 As String
r = "The following unexpected error occurred in Sub Form_Current,
CBF on " & ThisForm & "."
k = CRLF & CRLF & Str$(Err) & ": " & QUOTE & Error$ & QUOTE
Message3 = r & k
MsgBox Message3, 48, "Unexpected Error - " & MyApp$ & ", rev. " &
MY_VERSION$
Resume ExitForm_Current

End Sub
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

mlh, eit

unread,
Dec 30, 2001, 1:48:30 PM12/30/01
to
Sorry, but it does not work in Access 2.0.

You recommended...
MyOLE.visible=not isnull(MyOLE)

I used....
PictureClicker.Visible = Not IsNull(Pic)

PictureClicker is a command button control (normally not visible).
Pic is the Ole-type control being polled for a reference pointer.

[MyTable].[Pic] cannot have a value because its an Ole type field.
I can, however, have an entry. I believe that entry can be a reference
pointer to a graphic bitmap code. The graphic can be stored as a
separate file on disk. Or it can be integrated into the mdb itself. In
my case, its the latter. Dunno if that makes a difference.

Turtle

unread,
Dec 30, 2001, 8:30:13 PM12/30/01
to
Sorry, I no longer have a working copy of Access 2.0 on my machine.

If my memory serves me, treatment of OLE objects did change considerably
between Access 2.0 and 97.

Not that it's relevant here, but both options (linked and embedded) store a
copy of the bitmap image inside the mdb.
I'm quite sure that this has been the case in all versions since Access 2.0.
Since 97, it has been quite easy to store the image in a separate file and
display it in an image control; this could be done in Access 2.0 using an
unbound object frame, but this was a little more cumbersome.

Even in Access 2.0, I'd recommend storing the image in a separate file, and
at a maximum storing the path and filename in the Access database. Since
the stored data then becomes a text field, it's pretty simple to use Dir()
to check for the presence of a file by the name stored. Empty strings
should pose a minimal problem.

HTH
- Turtle

"mlh, eit" <Shak...@Triad.rr.com> wrote in message

news:k39out07r4d45oi88...@4ax.com...

0 new messages