![]() |
|
|
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. |
|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
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 > > > |
|
|||
|
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 > |
|
|||
|
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 >> >> >> |
|
|||
|
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 |
|
|||
|
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 > >> > >> > >> > > > |
|
|||
|
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 <-- |
![]() |
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|