Assemble strings into a message

B

BruceM

I have a database in which a fax message is built from strings. Some of the
strings depend on other strings. For instance (vairable in uppercase):
Your FISHING PERMIT expired in JULY

JULY is derived from a field ExpDate. FISHING PERMIT is from [PermitType].
If I define the string variables thus:

Dim strPermitType as
strPermitType = [PermitType]
strMsg = "Your " & strPermitType & " expired in " & strMonth
strMonth = Format([ExpDate],"mmmm")

I am left with strMsg:
Your FISHING PERMIT expired in

If I put strMonth before strMsg, all is well. However, my actual situation
is more complex (and is not about fishing permits), with about 20
interdependent strings, so I am hoping there is a way around the problems
(omissions) that result if they are in the wrong order.
 
B

BruceM

I left out the Dim statements by mistake. I did wonder if it matters
whether strMonth is a String or a Date in this case.
 
D

Douglas J. Steele

Definitely. It must be a string, not a date.

Date fields can only hold complete dates. Format([ExpDate],"mmmm") isn't a
date. Even if the Format function didn't convert its output to a string,
"July" isn't a date.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


BruceM said:
I left out the Dim statements by mistake. I did wonder if it matters
whether strMonth is a String or a Date in this case.

BruceM said:
I have a database in which a fax message is built from strings. Some of
the strings depend on other strings. For instance (vairable in
uppercase):
Your FISHING PERMIT expired in JULY

JULY is derived from a field ExpDate. FISHING PERMIT is from
[PermitType]. If I define the string variables thus:

Dim strPermitType as
strPermitType = [PermitType]
strMsg = "Your " & strPermitType & " expired in " & strMonth
strMonth = Format([ExpDate],"mmmm")

I am left with strMsg:
Your FISHING PERMIT expired in

If I put strMonth before strMsg, all is well. However, my actual
situation is more complex (and is not about fishing permits), with about
20 interdependent strings, so I am hoping there is a way around the
problems (omissions) that result if they are in the wrong order.
 
B

BruceM

OK, thanks. Actually, I am using a full date in places, but since I am
applying a format, I guess it would be a string for the reason you stated
about the Format function.

I'm still curious about the original question having to do with the order of
the strings. I ended up moving them around so that strMonth is assigned a
value before it is used in another string, but I wonder if there is an
alternative.

Douglas J. Steele said:
Definitely. It must be a string, not a date.

Date fields can only hold complete dates. Format([ExpDate],"mmmm") isn't a
date. Even if the Format function didn't convert its output to a string,
"July" isn't a date.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


BruceM said:
I left out the Dim statements by mistake. I did wonder if it matters
whether strMonth is a String or a Date in this case.

BruceM said:
I have a database in which a fax message is built from strings. Some of
the strings depend on other strings. For instance (vairable in
uppercase):
Your FISHING PERMIT expired in JULY

JULY is derived from a field ExpDate. FISHING PERMIT is from
[PermitType]. If I define the string variables thus:

Dim strPermitType as
strPermitType = [PermitType]
strMsg = "Your " & strPermitType & " expired in " & strMonth
strMonth = Format([ExpDate],"mmmm")

I am left with strMsg:
Your FISHING PERMIT expired in

If I put strMonth before strMsg, all is well. However, my actual
situation is more complex (and is not about fishing permits), with about
20 interdependent strings, so I am hoping there is a way around the
problems (omissions) that result if they are in the wrong order.
 
D

Douglas J. Steele

It only makes sense that

strPermitType = [PermitType]
strMsg = "Your " & strPermitType & " expired in " & strMonth
strMonth = Format([ExpDate],"mmmm")

would return Your FISHING PERMIT expired in

strMonth hasn't been assigned a value before it was used in strMsg.

Assignment statements work sequentially. If you had:

strMonth = "JUNE"
strMsg = "Your " & strPermitType & " expired in " & strMonth
strMonth = "JULY"

strMonth would still be Your FISHING PERMIT expired in JUNE.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


BruceM said:
OK, thanks. Actually, I am using a full date in places, but since I am
applying a format, I guess it would be a string for the reason you stated
about the Format function.

I'm still curious about the original question having to do with the order
of the strings. I ended up moving them around so that strMonth is
assigned a value before it is used in another string, but I wonder if
there is an alternative.

Douglas J. Steele said:
Definitely. It must be a string, not a date.

Date fields can only hold complete dates. Format([ExpDate],"mmmm") isn't
a date. Even if the Format function didn't convert its output to a
string, "July" isn't a date.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


BruceM said:
I left out the Dim statements by mistake. I did wonder if it matters
whether strMonth is a String or a Date in this case.

I have a database in which a fax message is built from strings. Some of
the strings depend on other strings. For instance (vairable in
uppercase):
Your FISHING PERMIT expired in JULY

JULY is derived from a field ExpDate. FISHING PERMIT is from
[PermitType]. If I define the string variables thus:

Dim strPermitType as
strPermitType = [PermitType]
strMsg = "Your " & strPermitType & " expired in " & strMonth
strMonth = Format([ExpDate],"mmmm")

I am left with strMsg:
Your FISHING PERMIT expired in

If I put strMonth before strMsg, all is well. However, my actual
situation is more complex (and is not about fishing permits), with
about 20 interdependent strings, so I am hoping there is a way around
the problems (omissions) that result if they are in the wrong order.
 
B

BruceM

Looks like there is no alternative but to assure they are in the correct
order. I suppose I could find a way to loop through them, but that seems
clumsy even if it works. Thanks for the feedback.

Douglas J. Steele said:
It only makes sense that

strPermitType = [PermitType]
strMsg = "Your " & strPermitType & " expired in " & strMonth
strMonth = Format([ExpDate],"mmmm")

would return Your FISHING PERMIT expired in

strMonth hasn't been assigned a value before it was used in strMsg.

Assignment statements work sequentially. If you had:

strMonth = "JUNE"
strMsg = "Your " & strPermitType & " expired in " & strMonth
strMonth = "JULY"

strMonth would still be Your FISHING PERMIT expired in JUNE.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


BruceM said:
OK, thanks. Actually, I am using a full date in places, but since I am
applying a format, I guess it would be a string for the reason you stated
about the Format function.

I'm still curious about the original question having to do with the order
of the strings. I ended up moving them around so that strMonth is
assigned a value before it is used in another string, but I wonder if
there is an alternative.

Douglas J. Steele said:
Definitely. It must be a string, not a date.

Date fields can only hold complete dates. Format([ExpDate],"mmmm") isn't
a date. Even if the Format function didn't convert its output to a
string, "July" isn't a date.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I left out the Dim statements by mistake. I did wonder if it matters
whether strMonth is a String or a Date in this case.

I have a database in which a fax message is built from strings. Some
of the strings depend on other strings. For instance (vairable in
uppercase):
Your FISHING PERMIT expired in JULY

JULY is derived from a field ExpDate. FISHING PERMIT is from
[PermitType]. If I define the string variables thus:

Dim strPermitType as
strPermitType = [PermitType]
strMsg = "Your " & strPermitType & " expired in " & strMonth
strMonth = Format([ExpDate],"mmmm")

I am left with strMsg:
Your FISHING PERMIT expired in

If I put strMonth before strMsg, all is well. However, my actual
situation is more complex (and is not about fishing permits), with
about 20 interdependent strings, so I am hoping there is a way around
the problems (omissions) that result if they are in the wrong order.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top