?
Solved

Access 2010 - VBA - show form recordsource field names

Posted on 2013-05-23
2
Medium Priority
?
1,650 Views
Last Modified: 2013-05-23
I have a subform with a recordsource that is set via code.  I want to do some debugging and just want to msgbox each field name in the form recordsource in the open event.

Can someone tell me some code snippets to step through the fields in a recordsource and give the field NAME.  (Eg. if the recordsource is CUSTOMER with fields NAME, ADDRESS1, etc, I want to see :
NAME
ADDRESS1
ADDRESS2
etc
0
Comment
Question by:MonkeyPie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Accepted Solution

by:
pdebaets earned 2000 total points
ID: 39193230
dim fld as dao.field
with forms!MyParentFormName!MySubformControlName.Form
    for each fld in .recordsetclone.fields
        msgbox fld.name
        '* or use debug.print
        'debug.print fld.name
    next fld
end with
set fld = nothing
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39193231
Dim rs as dao.recordset
Set rs = me.recordsetclone
Dim fld as field
For each fld  in rs.fields
     Debug.print fld.name
 Next
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question