Results 1 to 8 of 8
  1. #1
    chrisrach3 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    6

    can't auto fill

    I AM STUMPED.



    I have a field (Prospect Name) in a form (Listing Leads) that uses a combo box to select a name from "Contacts Query". The Contacts Query has 6 fields: FirstName, LastName, BusinessPhone, MobilePhone, EmailAddress, and Expr. Expr is "Expr: [FirstName] & " " & [LastName]". And it probably has about 1,100 records.

    So the Prospect Name field/combo box works GREAT, but I'd also like it to auto populate the rest of the fields in the Listing Leads form. Under "AfterUpdate", the code reads as follows:

    Email = DLookup("EmailAddress", "Contacts Query", "Expr")

    This is obviously only 1 of 6, but you get the point. And this brings up my 1st contact's email address, which is great. But as you can probably tell by the code, it brings up his address regardless of the name I type in the Prospect Name field. (I only point this out to let you know that it works up to this point.) So when I include the following code:

    Email = DLookup("EmailAddress", "Contacts Query", "Expr=" & Prospect Name)

    a dialog box opens that reads: "Compile error: Expected: list separator or)".

    Here's what the entire code looks like:


    Option Compare Database

    Private Sub Form_Open(Cancel As Integer)

    End Sub

    Private Sub Prospect_Name_AfterUpdate()

    Email = DLookup("EmailAddress", "Contacts Query", "Expr=" & Prospect Name)


    End Sub


    And here's the error message that comes up after I type someone's name in the Prospect Name field: "Compile Error: Syntax Error." And in the VBA, it highlights the following: Private Sub Prospect_Name_AfterUpdate()

    Any ideas?

  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
    This would be a lot more efficient:

    http://www.baldyweb.com/Autofill.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    chrisrach3 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    6
    Thank you for the feedback. What I'm doing with these is adding listing prospects, so I am essentially pasting this information into new records. I tried adding the following expression (?) into the control source field: =Property Name.Column(2) and nothing happened.

    It appears that I AM trying to save the information as an AfterUpdate function. At the end of your last post, what was the "Me" in your expression?

  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
    "Me" is a shortcut that can be used in code to refer to the object (form in this case) that the code is in. By the way, a source of your original problem is the inadvisable space in the field name. I'd change it, but you can work around it by bracketing it:

    [Property Name]
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    chrisrach3 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    6
    Thanks for the advice. I'll try that out today.

  6. #6
    chrisrach3 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    6
    Ugh. So frustrating. So I tried it and no luck whatsoever. I have the following box that pops up: Run-time error '3075': Syntax error (missing operator) in query expression 'expr=John Smith'. I've changed all of my field names to contain no spaces. When I debug, it highlights the following line:

    Email = DLookup("EmailAddress", "ContactsQuery", "expr=" & ProspectName)

    Am I doing something wrong? It's probably impossible to tell without actually taking a look at my computer. I also tried the idea from your website, and it translates to the following:

    [Listing Leads].Email = ContactsQuery.ProspectName.Column(2)

    After I run that, the popup reads: Run-time error '424': Object required. Ugh.

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    This does not look like proper syntax:


    [Listing Leads].Email = ContactsQuery.ProspectName.Column(2)

    You should refer to the controls on the form containing the values.

    Me.TextboxName = Me.ComboName.Column(x)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    Rasool Sarang is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    1
    Hi. Maybe this is useful: http://wp.me/pPUCs-1F

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

Similar Threads

  1. Auto-fill
    By sidewayzalex in forum Database Design
    Replies: 49
    Last Post: 09-14-2011, 11:12 AM
  2. Auto Fill
    By Kerrydunk in forum Forms
    Replies: 16
    Last Post: 04-26-2011, 12:15 AM
  3. Auto-Fill
    By sophiecormier in forum Programming
    Replies: 3
    Last Post: 10-02-2010, 08:29 AM
  4. Auto Fill-In Capability?
    By bbarrene in forum Access
    Replies: 3
    Last Post: 01-15-2010, 08:35 AM
  5. Auto fill a table?
    By newtoAccess in forum Access
    Replies: 3
    Last Post: 11-21-2009, 08:21 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