Re: textbox controsource as recordset field

Tech-Archive recommends: Speed Up your PC by fixing your registry



RedFish wrote:
>I'm a newbie to Access 2000, trying to set up a report here. I'm creating a
>recordset with a query, and want to assign the result to a textbox on the
>report. I've obviously got something wrong.
>
>'lcImport is defined by getting the result of a different query, on my
>import map.
>lcSelect = "SELECT [" & lcImport & "] AS myfield FROM MyTable1 WHERE [" &
>lcImport & "] NOT IN ( SELECT myfield FROM MyTable2 )"
>Set rstCD = dbs.OpenRecordset(lcSelect)
>
>Me.txtCD.ControlSource = rstCD.Fields("myfield")
>
>This results in a type mismatch, and I just don't know enough about how
>Access works to figure out why.


Aside from a potential name confusion of "myfield", I think
there is a very obscure thing going on here. If I am
interpreting your code correctly, I think the problem may
arise when the query does not return any records. You
should check the recordset's RecordCount property to make
sure it's greater than zero and add some code to deal with
the case when it is zero?

--
Marsh
MVP [MS Access]
.



Relevant Pages

  • Re: Conditional printing of records in the detail section of a rep
    ... The query option, as outlined in your post, doesn't work. ... The default data is zero. ... commands used in the Event Procedure? ... unbound form with a command button to open the report filtered, ...
    (microsoft.public.access.reports)
  • Re: Changing recordset?
    ... > query and append to that table from the second query and finally create a ... > trying to base the report on some sort of recordset created on the fly... ... You can bind a form to a recordset ...
    (microsoft.public.access.reports)
  • Re: Recording the frequency of Yes/No Fields
    ... Create a query. ... That will eliminate all the records where the number as zero. ... Or you can put a text box on the report if you wish. ... Tips for Access users - http://allenbrowne.com/tips.html ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Slow report
    ... Rahter there is a delay when the query is "rerun" for every ... As an example if the function opens a recordset, and you call it in a query ... There could be other causes for the slow report as well. ...
    (microsoft.public.access.reports)
  • Re: calendar report
    ... Create all the tables prior to opening the report. ... >> Use a temporary table that resembles your union query. ... In the calendar report, I ... >>> forms and subforms recordsource to the recordset, ...
    (microsoft.public.access.reports)