Solved

Access 2010 - VBA - show form recordsource field names

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
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…

733 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