[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Access 2010 - VBA - show form recordsource field names

Posted on 2013-05-23
2
Medium Priority
?
1,683 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

649 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