Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2003
    Posts
    15

    Question Unanswered: Get Value from query using VBA

    Hi every one

    Can anyone help me with the following,

    I need to be able to obtain a value from a query and assign it to a variable in VBA. The query will only have one value as it already has been filtered to show only one value through a criteria.

    Any sugestions?

    Thanks

    Chris

    "Hi Izy"

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    here's one way:

    you have a query yourQuery which returns a single row for field yourField

    dim aVariable as ...whatever is the type of yourField
    aVariable = DFIRST("[yourField]", "[yourQuery]")

    ...and i know that everyone hates domain aggregate functions but sometimes they are handy.

    izy
    currently using SS 2008R2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •