sql - How to view a recordset in an access table by means of vba? -
with of embedded access vb editor i've written small code analyse field values of database, , want view recordsets in table inside opened access. newbie can use debug.print display field names. of tell me statements/commands can execute sql string in order view result recordset values?
debug.print finalsqlstring
as far know, there no way display datasheet containing vba instance of recordset. if source of recordset strqsl, create table results, , open one, or more elegantly, create querydef , open it:
sub showqd(strqdname string, strsql string) 'creates querydef , display in datasheet' dim qd dao.querydef set qd = currentdb.createquerydef(strqdname) qd .returnsrecords = true .sql = strsql end docmd.openquery strqdname end sub
if focus on displaying things, put listbox in form, set number of columns number of fields returned query (qd.fields.count
), , set strsql rowsource of listbox. and... if put related code in form, have form can import in db display want :)
luck !
Comments
Post a Comment