Results 1 to 9 of 9
  1. #1
    Cedarguy is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    May 2012
    Posts
    37

    Obtaining a value in a form from a table

    I need to get a value from a table on to a form based on a value that exists on the form. The field being sought is part of the record being assembled that would be appended to a table. The only way I think I can get it is via an expression in the default value (properties) but have not succeeded. I have tried to use dlookup and select but the field starts out with #name? and then nothing.



    Is default value the right place to do this? I'm thinking not.

    Would appreciate some guidance.

    Thanks

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,619
    I just tested DLookup expression as a DefaultValue and it did work. Show your attempted code.

    Do you want to provide project for analysis? Follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Cedarguy is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    May 2012
    Posts
    37
    Thank you June7,
    Having trouble with compact & repair - it said the DB is in use; any suggestions?
    Meanwhile, my expression is: =DLookUp([Tutor]![Tut-Rate],[Tutor],[Tutor]![ID]=[Ses-Tutor ID])
    Note: Ses-Tutor ID is populated on the row being created, from a combobox which displays the names and IDs for tutors; naturally, the value would not be there when the screen is brought up; don't know if that a problem.
    Thanks again.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,619
    Arguments must be within quotes unless they are variables and variables must be concatenated. Brackets [] needed if name contains spaces, special characters or are reserved words.

    =DLookUp("Tut-Rate","Tutor","ID=" & [Ses-Tutor ID])

    And yes, if the Ses-Tutor ID value is not populated the default won't work. You will have to grab Tut-Rate through some other method. Options:
    1. table join
    2. multi-column combobox
    3. DLookup in event code

    Are you the only user of the db? With the file closed can you delete the ldb file? If the file is not so big without Compact & Repair, try zipping and attaching it anyway.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Cedarguy is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    May 2012
    Posts
    37
    Thanks for your helpful suggestions and comments, June7.
    I'll prep the DB for sending as an attachment next time I need to do so.
    I'll report back after trying your suggestions.
    Yes, I am the only user of the database and I'm porting my excel based small business data over to access, as excel can no longer handle the volume efficiently.
    Regards

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,619
    Okay, be aware none of the methods presented will actually save the value to the table. That will require code in some event.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Cedarguy is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    May 2012
    Posts
    37
    Thanks; that would mean learning something called VBA, right? LOL
    Would you be kind enough to refer me to a good VBA reference? I do have a distant programming background in procedural languages with only theoretical OO knowledge.
    With some practice I'm sure I'll pick up enough VBA to serve my proposes.
    Many thanks.

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,619
    Or macros but I don't use macros unless absolutely have to.

    Start with http://www.bing.com/search?q=access+...t&sp=1&sc=8-10

    I've never used a VBA specific reference, some VB6 and VB.net references and basic intro to Access.

    However, this one looks good
    Access™ 2007 Programming by Example with VBA, XML, and ASP by Julitta Korol, Wordware Publishing, Inc.

    If the field you want to save value to is included in the form's RecordSource, code could be simply like:

    Me!yourfieldname = Me.yourtextboxname

    The trick is figuring out what event to put the code in.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    Cedarguy is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    May 2012
    Posts
    37
    Thank you; I'll give your suggestions a shot later today; regards

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

Similar Threads

  1. Replies: 0
    Last Post: 12-29-2011, 05:21 PM
  2. Replies: 2
    Last Post: 08-01-2011, 11:35 PM
  3. Obtaining .net Webservice Data
    By Azmail in forum Programming
    Replies: 0
    Last Post: 01-26-2011, 08:36 PM
  4. Replies: 2
    Last Post: 12-22-2010, 01:46 PM
  5. Replies: 1
    Last Post: 03-08-2010, 02:32 AM

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