Solved

Access 2010 - VBA - show form recordsource field names

Posted on 2013-05-23
2
1,612 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 500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

690 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