Results 1 to 10 of 10
  1. #1
    MikeDBMan is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Feb 2011
    Location
    Stillwater, Oklahoma
    Posts
    23

    VBA Issue

    What is wrong with the select statement below. I can't get this to work.


    I have a table named "Billing People"
    It has fields: BillingPhone and Billing People.
    The field I just left is Billing Responsibility. I wish to lookup the data from the billing people table and populate the phone number in the current table. Thanks for any help...

    Code:
    Private Sub Billing_Responsibility_AfterUpdate()
    Dim ThePerson As String
    Dim Ans As Variant
    Dim Txt As String
    Dim Expr1 As String
    Let ThePerson = Me.Billing_Responsibility
    Dim Rec As Recordset
    Let Txt = "SELECT [Billing_People.BillingPhone] as Expr1 FROM [Billing_People] where [Billing_People.Billing_Responsibility] =" & "'" & ThePerson & "'"
    Let Ans = DLookup("[BillingPhone]", "Billing_People", Txt)
    Me.BillingPhone = Ans

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Is this what you want?

    http://www.baldyweb.com/Autofill.htm

    To answer your question, the criteria argument of the DLookup() just wants the WHERE clause, without the word WHERE. You don't want the Let keywords either. Just

    Ans = DLookup(...)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    MikeDBMan is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Feb 2011
    Location
    Stillwater, Oklahoma
    Posts
    23

    Still An Issue

    The code you provided works in that I get no errors but I always get the first record's data regardless of what I select in the field Billing Responsibility. Suggestions why this would be?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    What is the rowsource of the combo, and its bound column?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    MikeDBMan is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Feb 2011
    Location
    Stillwater, Oklahoma
    Posts
    23
    Row Source is Billing Responsibility and the bound Column is 1.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Can you post the db, or a representative sample?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    MikeDBMan is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Feb 2011
    Location
    Stillwater, Oklahoma
    Posts
    23
    I will have to strip some of the data from it. Let me see...

  8. #8
    MikeDBMan is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Feb 2011
    Location
    Stillwater, Oklahoma
    Posts
    23
    I have a file ready to upload. How do I go about doing that? I will see what I can find but I don't currently know how to do it.

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    There's a button to attach in the Post Reply or Go Advanced area.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    MikeDBMan is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Feb 2011
    Location
    Stillwater, Oklahoma
    Posts
    23

    Can't

    I can't get the size less than 500K so I can't get it uploadable.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Combo Box Issue
    By brandonze in forum Forms
    Replies: 4
    Last Post: 08-02-2011, 09:31 AM
  2. Issue with Do
    By Petefured in forum Programming
    Replies: 1
    Last Post: 05-25-2011, 09:27 AM
  3. List Box Issue
    By Igawa29 in forum Programming
    Replies: 4
    Last Post: 02-22-2011, 01:19 PM
  4. Crosstab issue
    By teedee in forum Queries
    Replies: 5
    Last Post: 02-07-2011, 10:49 AM
  5. Query Issue
    By access in forum Queries
    Replies: 1
    Last Post: 01-14-2010, 03:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums