i have form myform text box mytext.
in onload function, have written code supposed append rows recordset, a database's lockfile, mytext text box.
what happens is, first field of 4 fields appended textbox.
dim cn new adodb.connection dim cn2 new adodb.connection dim rs new adodb.recordset dim i, j long cn.provider = "microsoft.jet.oledb.4.0" cn.open "data source=z:\mydatabase.mdb" cn2.open "provider=microsoft.jet.oledb.4.0;" _ & "data source=z:\mydatabase.mdb" set rs = cn.openschema(adschemaproviderspecific, , "{947bb102-5d43-11d1-bdbf-00c04fb92675}") me.mytext.setfocus me.mytext.text = "" while not rs.eof me.mytext.text = me.mytext.text & rs.fields(0) & vbtab & rs.fields(1) & vbtab & _ rs.fields(2) & vbtab & rs.fields(3) & vbcrlf rs.movenext loop
i tried
debug.print rs.fields(0) & vbtab & rs.fields(1) & vbtab & rs.fields(2) & vbtab & rs.fields(3)
and 4 fields showed in immediate window.
edit: took out vbtab, since it's not supported , file has spaces, , changed me.mytext.text
in
me.mytext.text = me.mytext.text & rs.fields(0) & rs.fields(1) & _ rs.fields(2) & rs.fields(3) & vbcrlf
to me.mytext
. code seems work in beginning. when debug step step text box fills it's supposed to, when code exits while loop, first field of first row shows in text box.
debug.print me.mytext
before exiting loop shows rows. after exiting loop still shows rows. in form, textbox showing first record, first field.
the form , textbox both not have events other event, on forms load.
what wrong?
use property .value (which default property textbox) , not .text
so me.mytext.text ==> me.mytext.value or me.mytext
the textbox support multi line vbcrlf.
tab vbtab not supported
define myvbtab= " " tab separator instead of vbtab
modify following fragment of code:
myvbtab= " " dim row_data while not rs.eof row_data = rs.fields(0) & myvbtab& rs.fields(1) & _ myvbtab & rs.fields(2) & myvbtab& rs.fields(3) & vbcrlf me.mytext= me.mytext & row_data ' sure data displayed, know if control characters in row_data debug.print row_data rs.movenext loop
edit:
to isolate problem can run code:(independent of reading recordset)
me.mytext.value = "start " dim tabchar string tabchar = chr(9) '" " me.mytext = me.mytext & "one" & tabchar & "two" & vbcrlf me.mytext = me.mytext & "three" & tabchar & "four" & vbcrlf
it should display
start 1 2 3 4
Comments
Post a Comment