PC Review


Reply
Thread Tools Rate Thread

Assign Query Result to variable

 
 
Sean Timmons
Guest
Posts: n/a
 
      24th Sep 2008
I'm running a query to retrieve an e-mail address based on an employee name.
Easy enough.

Now, I'm trying to get the result of this query assigned to a variable to I
can use it in my SendObject command, and I can't figure it out.

I could just cheat and include the e-mail in my form as an invisible field,
but that's not very sporting...
 
Reply With Quote
 
 
 
 
Michel Walsh
Guest
Posts: n/a
 
      24th Sep 2008
You can use a DLookup:

var = DLookup("fieldName", "queryName", true)


You can also open a recordet, and read the first field of the first record.
Here, with a firehose recordset:

var = CurrentProject.Connection.Execute("queryName").Fields(0).Value

You can use a query and base your form on the query, rather than on a table,
directly.


Vanderghast, Access MVP


"Sean Timmons" <(E-Mail Removed)> wrote in message
news:8AD12D10-0169-4D84-90AC-(E-Mail Removed)...
> I'm running a query to retrieve an e-mail address based on an employee
> name.
> Easy enough.
>
> Now, I'm trying to get the result of this query assigned to a variable to
> I
> can use it in my SendObject command, and I can't figure it out.
>
> I could just cheat and include the e-mail in my form as an invisible
> field,
> but that's not very sporting...



 
Reply With Quote
 
Sean Timmons
Guest
Posts: n/a
 
      24th Sep 2008
That was absolutely perfect! The DLookup did all I needed! I can sleep
tonight! Thank you!

"Michel Walsh" wrote:

> You can use a DLookup:
>
> var = DLookup("fieldName", "queryName", true)
>
>
> You can also open a recordet, and read the first field of the first record.
> Here, with a firehose recordset:
>
> var = CurrentProject.Connection.Execute("queryName").Fields(0).Value
>
> You can use a query and base your form on the query, rather than on a table,
> directly.
>
>
> Vanderghast, Access MVP
>
>
> "Sean Timmons" <(E-Mail Removed)> wrote in message
> news:8AD12D10-0169-4D84-90AC-(E-Mail Removed)...
> > I'm running a query to retrieve an e-mail address based on an employee
> > name.
> > Easy enough.
> >
> > Now, I'm trying to get the result of this query assigned to a variable to
> > I
> > can use it in my SendObject command, and I can't figure it out.
> >
> > I could just cheat and include the e-mail in my form as an invisible
> > field,
> > but that's not very sporting...

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Assign Web Query Result to a Variable ron Microsoft Excel Programming 7 16th Aug 2008 10:51 PM
Assign the result of this simple query to a variable =?Utf-8?B?QXBleF9SVFg=?= Microsoft Access Queries 2 2nd Oct 2007 01:43 PM
Assign result of a query to a variable =?Utf-8?B?cmljaA==?= Microsoft Access Queries 9 6th Aug 2007 03:22 PM
Assign the result of an url to a variable...help trint Microsoft C# .NET 0 5th Sep 2005 08:48 PM
Assign result to variable Jim via DotNetMonster.com Microsoft ASP .NET 4 17th Mar 2005 10:23 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:51 PM.