Re: textbox controsource as recordset field

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



RedFish wrote:
>Here is a paste of the exact chunk of code, only
>with field and table names changed to protect the innocent (per company
>operating procedure). I've only changed the names, not the number of
>fields, tables, or any calculations or anything:
>
>lcSelect = "SELECT myField FROM myTable1 WHERE myField NOT IN ( SELECT [" &
>lcImport & "] FROM myTable2 )"
>Set rstHC = dbs.OpenRecordset(lcSelect)
>If rstHC.RecordCount > 0 Then
> Me.txtHC.ControlSource = rstHC.Fields("myField")
>Else
> Me.txtHC.Visible = False
>End If
>
>The field being returned in this query is a text field. I've made no
>changes to the textbox, just dropped it on the report. I assume it is set
>up to handle text by default. There is no data displayed on the report,
>only "#Name?". Does that help? I basically just started this job, don't
>want to break their rules yet, but I guess I will if I have to. I actually
>used a msgbox in the test I ran that displayed the number of records
>returned (17), so I know there is data. My guess here is that it is the
>controlsource assignment. Unfortunately, my lack of experience with this
>technology means that it is truly a guess.


#Name means that the text box's ControlSource is not the
name of a field in the form's RecordSource table/query.
This implies that either myfield in mytable is not an
acceptable field name OR that you only wanted to assign the
value of the field to the text box (instead of binding the
text box), If the latter is what you really want, then
don't use the ControlSource property:
Me.txtHC = rstHC.Fields("myField")

If I'm still missing the boat, please explain what you're
trying to accomplish and provide a few example values along
with the desired results.

--
Marsh
MVP [MS Access]
.



Relevant Pages

  • Re: How do I create Period Reports
    ... In opening my report, I set up an event stating: ... ControlSource was wrong. ... If pubMonth is a module-level public variable in the code module attached to ...
    (microsoft.public.access.reports)
  • Re: Scope issue? Variables passed from form to report with OpenArgs
    ... and you must declare the variable as global for the report module ... DIMmed as public variables in the Declarations section of the report ... are text boxes with experssions as the ControlSource) show #Name? ... bounded by double quotes)? ...
    (microsoft.public.access.formscoding)
  • Re: A ZLS being reported as null - Additional info
    ... It's do to with field/control naming and report optimization. ... DLookupcan't tell the difference between Null and ZLS. ... I started playing around with the fields some more and found the following - If the textbox Name and ControlSource are both Field1 then things "work". ...
    (microsoft.public.access.reports)
  • RE: Changing ControlSource property on a subform
    ... The report isn't closed, it is being opened - the OnOpen event. ... the parent report locks down the .ControlSource property, ...
    (microsoft.public.access.formscoding)
  • Re: A ZLS being reported as null - Additional info
    ... It's do to with field/control naming and report optimization. ... DLookupcan't tell the difference between Null and ZLS. ... ControlSource as Field1 then it reverts back to the undesired results. ...
    (microsoft.public.access.reports)