简体   繁体   中英

How to loop through the rows of a continuous form in microsoft access and insert value into unbound textbox using vba?

I have a continuous form of an access database table which is editable. I added a column to the form (not the access database table) and inserted an unbound textbox in this column with no value. When the form is loaded it runs a VBA that queries an online database, does some calculations and would like to insert those calculations into this unbound textbox in respect to that rows value.

在此处输入图像描述

I want the unbound textbox to show value respective to that row only, but instead the entire column of unbound text is assigned the same value.

I do not want to join tables as it makes the form not editable. I have also done dlookup, it works, but it makes the form extremely slow.

I have also tried using spacesaver columns like

select '' as column1, '' as column2 from table;

and used the vba records set to edit those values, but those space saver columns are not editable as its an expression. When i did

rs.Edit
rs.fields("column1") = "something"
rs.Update

the vba breaks when i do this as the the column i am trying to edit is an expression and is not editable.

You cant use an unbound textbox to do that. On a continuous form your unbound textbox will have the same value on each line. Internaly there is only one textbox that is printed on each line. There is not one textbox per line.

Try simply

Me.MyUnboundTextboxName = "SomeValue"

You'll see SomeValue appear on every line.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM