vba - QueryDefs returns ~sq_rrptStatTabRout -


situation: need lookup first field of each query. after created code listed below , executed received following debug.print:

~sq_rrptstattabrout qrybridgesub qrycenttabrout 

i expecting last 2 print i'm not particularly sure why first 1 did since rptstattabrout exist in database report.

question: there simple way explain or rid of it?

code:

private sub command47_click() dim db dao.database dim rs dao.recordset dim queries dao.querydefs dim query dao.querydef dim queryname string dim fld dao.field  set db = currentdb set queries = db.querydefs  ' loop through each query each query in queries     on error resume next      queryname = query.name     debug.print queryname     set rs = currentdb.openrecordset("select * " & queryname & "", dbopendynaset)     fld = rs.fields(0).name      msgbox fld  next  end sub 

seems want ignore saved queries names start ~. use if condition ignore them.

if not query.name "~*"    ' find first field end if 

note if want limit evaluation select queries, check each query's .type property. select query type dbqselect (0). check querydef.type property topic in access' system in case want process other query types.

if you're wondering ~sq_rrptstattabrout query came from, check record source property of rptstattabrout report. when source select statement, access saves statement hidden query. ~ prefix prevents being displayed in navigation pane.

the same thing happens when use select statement row source combo or list box.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -