Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Sacramento, California, USA
    Posts
    491
    Thanks
    0
    Thanked 0 Times in 0 Posts

    DCount (WIN XP 5.1 SP1 Acc2000)

    I am able to use Dcount like this:

    Dim x As Integer
    x = DCount("[EmpId]", "tblEmpl", "[EmpName] = 'Michael'")

    works fine.

    Now, I would the like the user to supply a name (where Michael is in above example)
    So I copied the code and stuck MyString where Michael is. Same quotes same everything else.

    Dim x As Integer
    Dim myString As String

    myString = InputBox("Enter a name")

    x = DCount("[EmpId]", "tblEmpl", "[EmpName] = 'myString'")

    Doesn't work <img src=/S/scratch.gif border=0 alt=scratch width=25 height=29> When I step through it, the variable myString does show what was entered
    into the input box. But it is not carrying over to the DCount.

    Can someone let me know what I'm missing?

    Thank you,
    Michael

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: DCount (WIN XP 5.1 SP1 Acc2000)

    Try this:

    x = DCount("[EmpId]", "tblEmpl", "[EmpName] = '" & myString & "'")

    HTH
    Pat <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  3. #3
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Sacramento, California, USA
    Posts
    491
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DCount (WIN XP 5.1 SP1 Acc2000)

    Of course, the good ol' ampersand !!!

    Thanks patt!!! Much appreciated

    Michael

Posting Permissions

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