A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

string field name



 
 
Thread Tools Display Modes
  #1  
Old May 12th, 2010, 01:48 PM posted to microsoft.public.access.reports
Judith
external usenet poster
 
Posts: 54
Default string field name

how do i refer to a dynamic field name please. I have fields month1, month2,
etc and only want to print the value for the current month
Something like

=val("[month" & [monthVal] & "]")

Thanks


  #2  
Old May 12th, 2010, 02:22 PM posted to microsoft.public.access.reports
John Spencer
external usenet poster
 
Posts: 7,815
Default string field name

One method:

Don't bind the control (txtShowCurrent) to anything (set its source to blank).

In the section containing the control you should be able to use VBA to assign
the value.

Me.txtShowCurrent = Me.Controls("Month" & Month(Date())

This solution would require you to have 12 non-visible controls on your report
in the relevant section bound to each of the 12 month fields.

Another option might be to use the DLookup function to get the value you want
from the report's record source. That depends on how your query is set up.
DLookup("Month" & Month(Date()),"SomeQueryOrTable")
This might require using the additional argument of DLookup to filter the result.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

judith wrote:
how do i refer to a dynamic field name please. I have fields month1, month2,
etc and only want to print the value for the current month
Something like

=val("[month" & [monthVal] & "]")

Thanks


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:58 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.