SetProperty to Field Values

  • Thread starter Thread starter Brian Carlson
  • Start date Start date
B

Brian Carlson

I have created a control button that OnClick runs a SetProperty macro. I am
trying to use the set caption. I am able to use literal text, but am
wondering if I can set both literal test and a current field value from the
form. I have tried numerous combinations, but nothing seems to work. Thank
you in advance.

Brian
 
Concatenate the value from the "field" into the Caption text:

"Literal Text " & [NameOfFieldInForm'sRecordSourceQuery]
 
Ken:
Thanks for the assistance, but I am trying to use the actual current value
in the field rather than the field name itself. I tried your suggestion just
to see if this would work and it creates an exact replica of what I enter.
That is, if I enter

"Literal Text " &[NameOfFieldInForm'sRecordSourceQuery]

then I get

"Literal Text " & [NameOfFieldInForm'sRecordSourceQuery]

returned as the caption. It seems to read the whole line as literal text.
Maybe I am doing something incorrectly?

Thank you,
Brian
Ken Snell (MVP) said:
Concatenate the value from the "field" into the Caption text:

"Literal Text " & [NameOfFieldInForm'sRecordSourceQuery]

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/


Brian Carlson said:
I have created a control button that OnClick runs a SetProperty macro. I
am
trying to use the set caption. I am able to use literal text, but am
wondering if I can set both literal test and a current field value from
the
form. I have tried numerous combinations, but nothing seems to work.
Thank
you in advance.

Brian
 
Steve:
Thank you. It works great now. One follow-up question, the field
from which the value for caption is being pulled is a date text box. When it
pulls it into the caption, it formats it 2_14_2009. Is there anyway that I
can change this to display 02142009, even if that means the text will appear
like this along with the caption. Thank you in advance for your assistance.

Brian


Steve Schapel said:
Brian,

Try putting an = sign in the beginning of the expression.

--
Steve Schapel, Microsoft Access MVP

Brian Carlson said:
Ken:
Thanks for the assistance, but I am trying to use the actual current value
in the field rather than the field name itself. I tried your suggestion
just
to see if this would work and it creates an exact replica of what I enter.
That is, if I enter

"Literal Text " &[NameOfFieldInForm'sRecordSourceQuery]

then I get

"Literal Text " & [NameOfFieldInForm'sRecordSourceQuery]

returned as the caption. It seems to read the whole line as literal text.
Maybe I am doing something incorrectly?
 
Steve:
Thank you for the assistance on this, though this does not seem to work.
If I enter it as you instructed it acts in the same manner as it was doing
without the =. I tried changing this format in both the table and the form,
while leaving the caption set to

='literal text' & [Name of Field]

but this continues to return the same value namely

literal text 2 14 2009

I woulf like it to be reading

literal text 02142009

This is I would no spaces with the leading zeros left in place. Any other
ideas? If not, I can always continue to rename the files, though automation
would be nice. In either case, thank you for your assistance on this.

Brian

Steve Schapel said:
Brian,

Try putting an = sign in the beginning of the expression.

--
Steve Schapel, Microsoft Access MVP

Brian Carlson said:
Ken:
Thanks for the assistance, but I am trying to use the actual current value
in the field rather than the field name itself. I tried your suggestion
just
to see if this would work and it creates an exact replica of what I enter.
That is, if I enter

"Literal Text " &[NameOfFieldInForm'sRecordSourceQuery]

then I get

"Literal Text " & [NameOfFieldInForm'sRecordSourceQuery]

returned as the caption. It seems to read the whole line as literal text.
Maybe I am doing something incorrectly?
 
Try this:

="Literal Text" & Format(Replace([YourDateDield], " ", "/"),"mmddyyyy")

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/



Brian Carlson said:
Steve:
Thank you for the assistance on this, though this does not seem to work.
If I enter it as you instructed it acts in the same manner as it was doing
without the =. I tried changing this format in both the table and the
form,
while leaving the caption set to

='literal text' & [Name of Field]

but this continues to return the same value namely

literal text 2 14 2009

I woulf like it to be reading

literal text 02142009

This is I would no spaces with the leading zeros left in place. Any other
ideas? If not, I can always continue to rename the files, though
automation
would be nice. In either case, thank you for your assistance on this.

Brian

Steve Schapel said:
Brian,

Try putting an = sign in the beginning of the expression.

--
Steve Schapel, Microsoft Access MVP

Brian Carlson said:
Ken:
Thanks for the assistance, but I am trying to use the actual current
value
in the field rather than the field name itself. I tried your
suggestion
just
to see if this would work and it creates an exact replica of what I
enter.
That is, if I enter

"Literal Text " &[NameOfFieldInForm'sRecordSourceQuery]

then I get

"Literal Text " & [NameOfFieldInForm'sRecordSourceQuery]

returned as the caption. It seems to read the whole line as literal
text.
Maybe I am doing something incorrectly?
 
Steve Schapel said:
Brian,

Try putting an = sign in the beginning of the expression.

Thanks, Steve... I inadvertently omitted that from my suggestion.
 
I don't understand, Brian. Did you try my earlier suggestion:
="Literal Text " & Format([YourDateDield],"mmddyyyy")
 
Thank you Ken and Steve for your assistance. One last question, could
someone please explain the syntax from Format on. What exactly are these
instructions saying to do? In addition, is there any references for
beginners which explains the syntax and uses of these statements...and any
beginners materials for VBA? Thanks again for the help.

Brian

Ken Snell (MVP) said:
Try this:

="Literal Text" & Format(Replace([YourDateDield], " ", "/"),"mmddyyyy")

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/



Brian Carlson said:
Steve:
Thank you for the assistance on this, though this does not seem to work.
If I enter it as you instructed it acts in the same manner as it was doing
without the =. I tried changing this format in both the table and the
form,
while leaving the caption set to

='literal text' & [Name of Field]

but this continues to return the same value namely

literal text 2 14 2009

I woulf like it to be reading

literal text 02142009

This is I would no spaces with the leading zeros left in place. Any other
ideas? If not, I can always continue to rename the files, though
automation
would be nice. In either case, thank you for your assistance on this.

Brian

Steve Schapel said:
Brian,

Try putting an = sign in the beginning of the expression.

--
Steve Schapel, Microsoft Access MVP

Ken:
Thanks for the assistance, but I am trying to use the actual current
value
in the field rather than the field name itself. I tried your
suggestion
just
to see if this would work and it creates an exact replica of what I
enter.
That is, if I enter

"Literal Text " &[NameOfFieldInForm'sRecordSourceQuery]

then I get

"Literal Text " & [NameOfFieldInForm'sRecordSourceQuery]

returned as the caption. It seems to read the whole line as literal
text.
Maybe I am doing something incorrectly?
 
Ken:
I forgot to note that your explanation below worked perfectly, though I
do not understand the syntax of it.

Thank You,
Brian

Ken Snell (MVP) said:
Try this:

="Literal Text" & Format(Replace([YourDateDield], " ", "/"),"mmddyyyy")

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/



Brian Carlson said:
Steve:
Thank you for the assistance on this, though this does not seem to work.
If I enter it as you instructed it acts in the same manner as it was doing
without the =. I tried changing this format in both the table and the
form,
while leaving the caption set to

='literal text' & [Name of Field]

but this continues to return the same value namely

literal text 2 14 2009

I woulf like it to be reading

literal text 02142009

This is I would no spaces with the leading zeros left in place. Any other
ideas? If not, I can always continue to rename the files, though
automation
would be nice. In either case, thank you for your assistance on this.

Brian

Steve Schapel said:
Brian,

Try putting an = sign in the beginning of the expression.

--
Steve Schapel, Microsoft Access MVP

Ken:
Thanks for the assistance, but I am trying to use the actual current
value
in the field rather than the field name itself. I tried your
suggestion
just
to see if this would work and it creates an exact replica of what I
enter.
That is, if I enter

"Literal Text " &[NameOfFieldInForm'sRecordSourceQuery]

then I get

"Literal Text " & [NameOfFieldInForm'sRecordSourceQuery]

returned as the caption. It seems to read the whole line as literal
text.
Maybe I am doing something incorrectly?
 
The Help files for ACCESS explain how to use functions such as Replace and
Format.

In this expression:

="Literal Text" & Format(Replace([YourDateDield], " ", "/"),"mmddyyyy")


The Replace function is replacing all instances of a blank space with a /
character. This essentially converts your "date" string into a format that
is understood by ACCESS to be a date value, even though it's a string. So,
"2 13 2009" is converted to "2/13/2009" by the Replace function.

Then, the Format function tells ACCESS how to display the resulting date
value. The second argument, "mmddyyyy", tells ACCESS to use that format for
the display. Therefore, the Format function changes "2/13/2009" into
"02132009".

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/


Brian Carlson said:
Ken:
I forgot to note that your explanation below worked perfectly, though I
do not understand the syntax of it.

Thank You,
Brian

Ken Snell (MVP) said:
Try this:

="Literal Text" & Format(Replace([YourDateDield], " ", "/"),"mmddyyyy")

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/



Brian Carlson said:
Steve:
Thank you for the assistance on this, though this does not seem to
work.
If I enter it as you instructed it acts in the same manner as it was
doing
without the =. I tried changing this format in both the table and the
form,
while leaving the caption set to

='literal text' & [Name of Field]

but this continues to return the same value namely

literal text 2 14 2009

I woulf like it to be reading

literal text 02142009

This is I would no spaces with the leading zeros left in place. Any
other
ideas? If not, I can always continue to rename the files, though
automation
would be nice. In either case, thank you for your assistance on this.

Brian

:

Brian,

Try putting an = sign in the beginning of the expression.

--
Steve Schapel, Microsoft Access MVP

message
Ken:
Thanks for the assistance, but I am trying to use the actual current
value
in the field rather than the field name itself. I tried your
suggestion
just
to see if this would work and it creates an exact replica of what I
enter.
That is, if I enter

"Literal Text " &[NameOfFieldInForm'sRecordSourceQuery]

then I get

"Literal Text " & [NameOfFieldInForm'sRecordSourceQuery]

returned as the caption. It seems to read the whole line as literal
text.
Maybe I am doing something incorrectly?
 
Ken:
Thanks for the explanation.

Brian

Ken Snell (MVP) said:
The Help files for ACCESS explain how to use functions such as Replace and
Format.

In this expression:

="Literal Text" & Format(Replace([YourDateDield], " ", "/"),"mmddyyyy")


The Replace function is replacing all instances of a blank space with a /
character. This essentially converts your "date" string into a format that
is understood by ACCESS to be a date value, even though it's a string. So,
"2 13 2009" is converted to "2/13/2009" by the Replace function.

Then, the Format function tells ACCESS how to display the resulting date
value. The second argument, "mmddyyyy", tells ACCESS to use that format for
the display. Therefore, the Format function changes "2/13/2009" into
"02132009".

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/


Brian Carlson said:
Ken:
I forgot to note that your explanation below worked perfectly, though I
do not understand the syntax of it.

Thank You,
Brian

Ken Snell (MVP) said:
Try this:

="Literal Text" & Format(Replace([YourDateDield], " ", "/"),"mmddyyyy")

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/



Steve:
Thank you for the assistance on this, though this does not seem to
work.
If I enter it as you instructed it acts in the same manner as it was
doing
without the =. I tried changing this format in both the table and the
form,
while leaving the caption set to

='literal text' & [Name of Field]

but this continues to return the same value namely

literal text 2 14 2009

I woulf like it to be reading

literal text 02142009

This is I would no spaces with the leading zeros left in place. Any
other
ideas? If not, I can always continue to rename the files, though
automation
would be nice. In either case, thank you for your assistance on this.

Brian

:

Brian,

Try putting an = sign in the beginning of the expression.

--
Steve Schapel, Microsoft Access MVP

message
Ken:
Thanks for the assistance, but I am trying to use the actual current
value
in the field rather than the field name itself. I tried your
suggestion
just
to see if this would work and it creates an exact replica of what I
enter.
That is, if I enter

"Literal Text " &[NameOfFieldInForm'sRecordSourceQuery]

then I get

"Literal Text " & [NameOfFieldInForm'sRecordSourceQuery]

returned as the caption. It seems to read the whole line as literal
text.
Maybe I am doing something incorrectly?
 
iletisinde ÅŸunu said:
I have created a control button that OnClick runs a SetProperty macro. I
am
trying to use the set caption. I am able to use literal text, but am
wondering if I can set both literal test and a current field value from
the
form. I have tried numerous combinations, but nothing seems to work.
Thank
you in advance.

Brian
 
Back
Top