Why can Form VBA "see" a field's value but the UI and form reference shows 0

mdlueck

Sr. Application Developer
Local time
Today, 01:59
Joined
Jun 23, 2011
Messages
2,650
Why can Form VBA "see" a field's value but the UI and form reference shows 0

I have an odd situation while adding some business logic to a form. On an Edit record form, this form has several look-up values, each with a record selection form. I use inter-form dialog and opening those record picker forms via the form class to acheve the inter-form dialog.

All have appeared to work great, and I have long since hiddng the fields holding the looked up record ID, and left the "pretty text" field visible.

The one of these I need to add some business logic to, keeps thinking it is returning ID = 0, which is not a valid value. I have unhidden the ID holder field, and indeed it always shows 0.

I unhid another ID field, and that ID field is behaving as expected... holds the ID of the record from the pick list form.

I have added some debugging in the call-back event, and I see the data sail through...

Code:
    'If it really did change...
    If Me.fldstocktypeid.Value <> ObjResponsePartsPickListValue.id Then
      Me.fldstocktypeid.Value = ObjResponsePartsPickListValue.id
      Debug.Print "The Response Obj: " & ObjResponsePartsPickListValue.id
      Debug.Print "The Field Ctrl: " & Me.fldstocktypeid.Value
      Me.fldstocktypetitle.Value = ObjResponsePartsPickListValue.title
      ...
Shows me in the immediate window:

Code:
The Response Obj: 2
The Field Ctrl: 2
Ideas why the field shows always 0 even though the data is flowing to it?

Later another class tries to interrogate that same field, and that class as well is receiving a 0 value. Yikes, I am suspecting form corruption, and this is one of the two most complicated forms in this application... lots of time to have to rebuild it.
 
Re: Why can Form VBA "see" a field's value but the UI and form reference shows 0

Nothing like getting the wrong objects on the wrong side of the = sign to make programs behave very strangely! Hurrying, that is what I did this morning. Problem solved.
 

Users who are viewing this thread

Back
Top Bottom