Solved

Access 2010 - VBA - show form recordsource field names

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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Suggested Solutions

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now