Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setvalue statement not working

Status
Not open for further replies.

kmclane

Technical User
Apr 14, 2004
321
US
I have a text box I want to change dynamically. I am trying to set this value when the form is opened. This is what I have, that does not work:
Me.Head = "Settlement Report - " & Month & " " & Year

The end result I want is "Settlement Report - May 2004". but I want the month and year to change as time goes on. Someone is always forgetting to edit the thing, and then half the reports need to be reprinted.
Thanks for any suggestions, Ken

- If you are flammable and have legs, you are never blocking a fire exit.
Mitch Hedburg
 
Suggestion -- is this field bound? You may want to create 3 bound text boxes and enter the information you indicated as the defualt value respectively.

1. Settlement Report (type of report)
2. Month (month)
3. Year (year)
You could then format #2 & #3 to show only what you want.

By putting these fields in a table you can then sort at a future date.

This is most likely the easiest way, but there are others.

Good Luck!

An investment in knowledge always pays the best dividends.
by Benjamin Franklin
Autonumber Description - FAQ702-5106
 
Something like this ?
Me.Head = "Settlement Report - " & Format(Date(), "mmmm yyyy")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PH, will that give me the word May, or the number? I may combine these two suggestions.
Ken

- If you are flammable and have legs, you are never blocking a fire exit.
Mitch Hedburg
 
BTW that is an unbound field. I tried PH's code in the on open event of my form and got the dreaded "you can't assign a value to this object" error. Any Ideas?
Ken

- If you are flammable and have legs, you are never blocking a fire exit.
Mitch Hedburg
 
I even tried just Me.Head = "Settlement Report -"
and still get the error 2448 - You can't assign....
Very strange, I saw something in another post that said you can't do this in the onopen event, but someone else rebutted. I'll try it somewhere else.
Ken

- If you are flammable and have legs, you are never blocking a fire exit.
Mitch Hedburg
 
Sorry for not making myself clearer.

Field Default Value

1. Type of report Settlement Report

2. Month Date()mmmm

3. Year Date()yyyy

The problem you are encountering with error 2448 is another reason I suggested to make them bound.The following is a description of the error:
You can't assign a value to this object.@* The object may be a control on a read-only form.
* The object may be on a form that is open in Design view.
* The value may be too large for this field.@@1@209424@1




An investment in knowledge always pays the best dividends.
by Benjamin Franklin
Autonumber Description - FAQ702-5106
 
Hey, it works in the on format event of the header. Two more questions.
1. Do I need More MMM's so I get the full name of each month? So to cover them all I would need 9?
2. Since I run these for the prior month, how would I modify the code to pull the previous month?
Ken

- If you are flammable and have legs, you are never blocking a fire exit.
Mitch Hedburg
 
1) From the helpfile:[tt]
"m" 1 .. 12
"mm" 01 .. 12
"mmm" jan .. dec
"mmmm" january .. december[/tt]
2) You may try something like this:
Format(DateAdd("m", -1, Date()), "mmmm yyyy")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top