Welcome to the { mindfrost82.com } forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Go Back   { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Access

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-07-2008, 03:25 PM
Jeff G
 
Posts: n/a
Converting A String To A Command

All -

I've modified a module that sends an object in Access 2007. Where my
problem is...on a Form where I'm collecting data to pass through to the
Function, I need to convert the string into a command, if that makes sense.

The command in the module is...

DoCmd.OutputTo OutputType, ItemName, AttachmentType,
"C:\Temp\DatabaseExport\" & AttachmentName & "." & AttachmentExtension

The function is...
EMailAttachment(ItemName As String, OutputType As String, AttachmentName As
String, AttachmentType As String, AttachmentExtension As String,
ReceipientEMail As String, EMailSubject As String, EMailMessage As String)

The problem comes in where the OutputType is being collected as a String
(i.e. "acOutputQuery"), but I need to change it to a command (i.e.
acOutputQuery), basically stripping it of the quotes.

Any help would be greatly appreciated.

Jeff G


Reply With Quote
  #2 (permalink)  
Old 08-07-2008, 04:37 PM
Chris O'C via AccessMonster.com
 
Posts: n/a
Re: Converting A String To A Command

Why convert it to a string in the first place? Change the parameters of the
function to:

EMailAttachment(ItemName As String, OutputType As Byte, AttachmentName As
String, AttachmentType As String, AttachmentExtension As String,
ReceipientEMail As String, EMailSubject As String, EMailMessage As String)

And when you call the function in your procedure, use whatever
AcOutputObjectType constant you need:

call EMailAttachment(strItemName, acOutputQuery, strAttachmentName, etc ...

Chris
Microsoft MVP



Jeff G wrote:
>All -
>
>I've modified a module that sends an object in Access 2007. Where my
>problem is...on a Form where I'm collecting data to pass through to the
>Function, I need to convert the string into a command, if that makes sense.
>
>The command in the module is...
>
>DoCmd.OutputTo OutputType, ItemName, AttachmentType,
>"C:\Temp\DatabaseExport\" & AttachmentName & "." & AttachmentExtension
>
>The function is...
>EMailAttachment(ItemName As String, OutputType As String, AttachmentName As
>String, AttachmentType As String, AttachmentExtension As String,
>ReceipientEMail As String, EMailSubject As String, EMailMessage As String)
>
>The problem comes in where the OutputType is being collected as a String
>(i.e. "acOutputQuery"), but I need to change it to a command (i.e.
>acOutputQuery), basically stripping it of the quotes.


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200808/1

Reply With Quote
  #3 (permalink)  
Old 08-07-2008, 04:37 PM
=?Utf-8?B?S2xhdHV1?=
 
Posts: n/a
RE: Converting A String To A Command

Is isn't clear to me what you are trying to accomplish, but look in VBA help
for the Eval() function. It may be what you want.
--
Dave Hargis, Microsoft Access MVP


"Jeff G" wrote:

> All -
>
> I've modified a module that sends an object in Access 2007. Where my
> problem is...on a Form where I'm collecting data to pass through to the
> Function, I need to convert the string into a command, if that makes sense.
>
> The command in the module is...
>
> DoCmd.OutputTo OutputType, ItemName, AttachmentType,
> "C:\Temp\DatabaseExport\" & AttachmentName & "." & AttachmentExtension
>
> The function is...
> EMailAttachment(ItemName As String, OutputType As String, AttachmentName As
> String, AttachmentType As String, AttachmentExtension As String,
> ReceipientEMail As String, EMailSubject As String, EMailMessage As String)
>
> The problem comes in where the OutputType is being collected as a String
> (i.e. "acOutputQuery"), but I need to change it to a command (i.e.
> acOutputQuery), basically stripping it of the quotes.
>
> Any help would be greatly appreciated.
>
> Jeff G
>
>
>

Reply With Quote
  #4 (permalink)  
Old 08-07-2008, 05:20 PM
Jeff G
 
Posts: n/a
Re: Converting A String To A Command

Chris -

I'm using TempVars in a macro to pass the variables to the function. If I
don't put the name in quotes, it assumes it's a field and puts brackets
around it. When you run the macro, it comes back and says it can't find the
name. That's why I'm assuming that these are Strings in the Macro's
TempVar's that need to be converted.

"Chris O'C via AccessMonster.com" <u29189@uwe> wrote in message
news:8851dadb1e0f5@uwe...
> Why convert it to a string in the first place? Change the parameters of
> the
> function to:
>
> EMailAttachment(ItemName As String, OutputType As Byte, AttachmentName As
> String, AttachmentType As String, AttachmentExtension As String,
> ReceipientEMail As String, EMailSubject As String, EMailMessage As String)
>
> And when you call the function in your procedure, use whatever
> AcOutputObjectType constant you need:
>
> call EMailAttachment(strItemName, acOutputQuery, strAttachmentName, etc
> ...
>
> Chris
> Microsoft MVP
>
>
>
> Jeff G wrote:
>>All -
>>
>>I've modified a module that sends an object in Access 2007. Where my
>>problem is...on a Form where I'm collecting data to pass through to the
>>Function, I need to convert the string into a command, if that makes
>>sense.
>>
>>The command in the module is...
>>
>>DoCmd.OutputTo OutputType, ItemName, AttachmentType,
>>"C:\Temp\DatabaseExport\" & AttachmentName & "." & AttachmentExtension
>>
>>The function is...
>>EMailAttachment(ItemName As String, OutputType As String, AttachmentName
>>As
>>String, AttachmentType As String, AttachmentExtension As String,
>>ReceipientEMail As String, EMailSubject As String, EMailMessage As String)
>>
>>The problem comes in where the OutputType is being collected as a String
>>(i.e. "acOutputQuery"), but I need to change it to a command (i.e.
>>acOutputQuery), basically stripping it of the quotes.

>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/For...ccess/200808/1
>



Reply With Quote
  #5 (permalink)  
Old 08-07-2008, 05:23 PM
Jeff G
 
Posts: n/a
Re: Converting A String To A Command

What I'm trying to accomplish is to use a Function that I can pass variables
back to, instead of have to keep re-using the same code over and over. All
of the variables are being passed from a Macro's TempVar, but they have to
be Strings, unless I'm mistaken. But, then OutputType cannot be a String.


"Klatuu" <Klatuu@discussions.microsoft.com> wrote in message
news:0916BB32-F1B3-40FC-A91C-29ECAAB5F483@microsoft.com...
> Is isn't clear to me what you are trying to accomplish, but look in VBA
> help
> for the Eval() function. It may be what you want.
> --
> Dave Hargis, Microsoft Access MVP
>
>
> "Jeff G" wrote:
>
>> All -
>>
>> I've modified a module that sends an object in Access 2007. Where my
>> problem is...on a Form where I'm collecting data to pass through to the
>> Function, I need to convert the string into a command, if that makes
>> sense.
>>
>> The command in the module is...
>>
>> DoCmd.OutputTo OutputType, ItemName, AttachmentType,
>> "C:\Temp\DatabaseExport\" & AttachmentName & "." & AttachmentExtension
>>
>> The function is...
>> EMailAttachment(ItemName As String, OutputType As String, AttachmentName
>> As
>> String, AttachmentType As String, AttachmentExtension As String,
>> ReceipientEMail As String, EMailSubject As String, EMailMessage As
>> String)
>>
>> The problem comes in where the OutputType is being collected as a String
>> (i.e. "acOutputQuery"), but I need to change it to a command (i.e.
>> acOutputQuery), basically stripping it of the quotes.
>>
>> Any help would be greatly appreciated.
>>
>> Jeff G
>>
>>
>>



Reply With Quote
  #6 (permalink)  
Old 08-07-2008, 05:37 PM
Chris O'C via AccessMonster.com
 
Posts: n/a
Re: Converting A String To A Command

Despite the media hype, Access macros are very, very limited. You have two
choices:

1 - convert the macro to a vba procedure.
2 - use a select case block within the EMailAttachment function to evaluate
the OutputType string passed from the macro and assign the correct constant
to use in the OutputTo procedure.

I'd recommend #1.

Chris
Microsoft MVP


Jeff G wrote:
>Chris -
>
>I'm using TempVars in a macro to pass the variables to the function. If I
>don't put the name in quotes, it assumes it's a field and puts brackets
>around it. When you run the macro, it comes back and says it can't find the
>name. That's why I'm assuming that these are Strings in the Macro's
>TempVar's that need to be converted.


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200808/1

Reply With Quote
  #7 (permalink)  
Old 08-08-2008, 04:40 PM
=?Utf-8?B?S2xhdHV1?=
 
Posts: n/a
Re: Converting A String To A Command

acOutputQuery is not a command, it is an instrinsic constant. That is, a
define constant value built into Access. Read a bit about constants in VBA
Help.
The purpose of contstants is to make values understandable to we human types.

For example, the value of acOutputQuery is 1. A computer easily understands
1 in the context where it is used, but we humans would have a hard time
remembering all the numeric options, so when we see acOutputQuery, we know
from the ac part it is an Access contstant and the rest means we are going to
output a query.

Sort of like True and False. They are not commands, they are contstants
True = -1 False = 0

As to whether it is a problem it being a number or a string in the macro, I
think it will work. If not, you can use the actual value of 1. Since I
never use queries, I can't tell you for sure how it works.
--
Dave Hargis, Microsoft Access MVP


"Jeff G" wrote:

> What I'm trying to accomplish is to use a Function that I can pass variables
> back to, instead of have to keep re-using the same code over and over. All
> of the variables are being passed from a Macro's TempVar, but they have to
> be Strings, unless I'm mistaken. But, then OutputType cannot be a String.
>
>
> "Klatuu" <Klatuu@discussions.microsoft.com> wrote in message
> news:0916BB32-F1B3-40FC-A91C-29ECAAB5F483@microsoft.com...
> > Is isn't clear to me what you are trying to accomplish, but look in VBA
> > help
> > for the Eval() function. It may be what you want.
> > --
> > Dave Hargis, Microsoft Access MVP
> >
> >
> > "Jeff G" wrote:
> >
> >> All -
> >>
> >> I've modified a module that sends an object in Access 2007. Where my
> >> problem is...on a Form where I'm collecting data to pass through to the
> >> Function, I need to convert the string into a command, if that makes
> >> sense.
> >>
> >> The command in the module is...
> >>
> >> DoCmd.OutputTo OutputType, ItemName, AttachmentType,
> >> "C:\Temp\DatabaseExport\" & AttachmentName & "." & AttachmentExtension
> >>
> >> The function is...
> >> EMailAttachment(ItemName As String, OutputType As String, AttachmentName
> >> As
> >> String, AttachmentType As String, AttachmentExtension As String,
> >> ReceipientEMail As String, EMailSubject As String, EMailMessage As
> >> String)
> >>
> >> The problem comes in where the OutputType is being collected as a String
> >> (i.e. "acOutputQuery"), but I need to change it to a command (i.e.
> >> acOutputQuery), basically stripping it of the quotes.
> >>
> >> Any help would be greatly appreciated.
> >>
> >> Jeff G
> >>
> >>
> >>

>
>
>

Reply With Quote
  #8 (permalink)  
Old 08-11-2008, 10:36 AM
Stefan Hoffmann
 
Posts: n/a
Re: Converting A String To A Command

hi Jeff,

Jeff G wrote:
> The problem comes in where the OutputType is being collected as a String
> (i.e. "acOutputQuery"), but I need to change it to a command (i.e.
> acOutputQuery), basically stripping it of the quotes.

Use a Select Case statement:

Dim OutputObjectType As Access.AcOutputObjectType

Select Case yourString
Case Is = "acOutputQuery"
OutputObjectType = acOutputQuery
Case Is = "acOutputForm"
OutputObjectType = acOutputForm
Case...
End Select

DoCmd.OutputTo OutputObjectType, ...


mfG
--> stefan <--


Reply With Quote
Reply

  { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Access


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:51 PM.


Powered by vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
© 1999-2008 mindfrost82.com v11.0


Sponsors:
Buy Playstation 3 | Credit Cards | Credit Cards | Credit Cards | Remortgages



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114