Object exists...and it doesn't

  • Thread starter Thread starter FP1
  • Start date Start date
F

FP1

Some kind of zen thing in Access, maybe? I'm calling a procedure with an
optional paramter. I'm NOT passing that parameter in the calling procedure
and therefore the object should be "missing". Access returns False from
IsMissing, IsEmpty and IsNull, and of course I then get "object or with
variable not set" when I try to access it. Any ideas?

Sub check_for_records_added(oldDB As ADODB.Connection, newDB As
ADODB.Connection, updatedTable, outOfDateTable, keyfields As Collection,
Optional outkeyfields As Collection)

Dim outkeys As Collection

'irrelevant stuff snipped

If (IsMissing(outkeyfields) or Isnull(outkeyfields)) Then
Set outkeys = keyfields
Else
Set outkeys = outkeyfields '<--always true
End If
 
The IsMissing only works with Variant data types. It will not work with an
object variable.
 
The IsMissing only works with Variant data types. It will not work
with an object variable.

Ouch! Thanks. So how would I check it? Isnull and Isempty return false.
Would I use "is Nothing"?
 
If they are class objects, I don't think passing them as collections
is correct.
It isn't clear to me what these objects contain or what it is you are
trying to do.
Maybe a description of the intent would be helpful.

Actually, they are collections. It's pretty simple, really. I'm building a
comparision of two tables in different database with potentially
differently primary keys (same basic keys, but could have differnt names).
If they're different, I pass the secod set names, but if not, just copy the
first set.

Probably the best answer was the first one, that I can't check for a
missing object if it's not a variant. Been coding access for over three
years and I still run into this stuff!
 
If they are class objects, I don't think passing them as collections is
correct.
It isn't clear to me what these objects contain or what it is you are trying
to do.
Maybe a description of the intent would be helpful.
 
Back
Top