G
Guest
Hello,
I'm using Access 2003. I have a form with a combo box control whose Row
Source is set to a query. On Form Load I had originally set the control's
initial value to a hard-coded value:
Me.cmbControl.Text = "Dave"
This worked fine, however I now need to set the control's .Text property
more programmatically, and hard-coding "Dave" will no longer suffice in the
long run. I have tried without success to access the control's Recordset:
Me.cmbControl.Text = Me.cmbControl.Recordset.Fields(2).Value
This yields the error:
"Object or with block variable not set"
However, if I add this field to the Watch, Me.cmbControl, and I expand that
field within the Watch to Recordset->Fields->Item 3->Value, then try and step
through, it works. On its own it does not recognize the object,
Me.cmbControl.Recordset.Fields(2).Value, but if I "help it along" by
expanding to this value in the Watch, it works fine (FYI, after I do this,
Me.cmbControl.Recordset.Fields(2).Value does in fact = "Dave" within the
Watch, which is the correct result from the query).
Just not sure how the control can arrive at this result on its own as the
form loads, instead of giving me the "Object or with block variable not set"
error.
Any ideas?
Thanks,
Scott
I'm using Access 2003. I have a form with a combo box control whose Row
Source is set to a query. On Form Load I had originally set the control's
initial value to a hard-coded value:
Me.cmbControl.Text = "Dave"
This worked fine, however I now need to set the control's .Text property
more programmatically, and hard-coding "Dave" will no longer suffice in the
long run. I have tried without success to access the control's Recordset:
Me.cmbControl.Text = Me.cmbControl.Recordset.Fields(2).Value
This yields the error:
"Object or with block variable not set"
However, if I add this field to the Watch, Me.cmbControl, and I expand that
field within the Watch to Recordset->Fields->Item 3->Value, then try and step
through, it works. On its own it does not recognize the object,
Me.cmbControl.Recordset.Fields(2).Value, but if I "help it along" by
expanding to this value in the Watch, it works fine (FYI, after I do this,
Me.cmbControl.Recordset.Fields(2).Value does in fact = "Dave" within the
Watch, which is the correct result from the query).
Just not sure how the control can arrive at this result on its own as the
form loads, instead of giving me the "Object or with block variable not set"
error.
Any ideas?
Thanks,
Scott