Results 1 to 7 of 7
  1. #1
    Darlene is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    5

    Setting a default value for a field on a form

    I have a form for which I would like to prompt the user for a default field value each time the form is opened. For this application the "project ID" will be the same for the entire day. I'd like to prompt them when the form opens and have that field value be the default until the form is closed. I know I can put a prompt on the query which populates the form, but I don't want it filtered to that value - I just want that value as the default for new records.



    I am a very light Access user so if you have the patience to really spell this out for me I would greatly appreciate it.

    How can I do that? Thanks.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Need VBA code, probably in form Open event. One approach to try:

    Me.textboxname.DefaultValue = InputBox("Enter default value.")

    Review
    http://office.microsoft.com/en-us/ac...010341717.aspx
    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
    Darlene is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    5
    Thank you so much for the quick response! I put in the code, I get the nice prompt, but when I add a record that field displays #Name? as shown below. I'm sorry I am a very beginner. Do I need to add something to the default value field within the field's properties also or should that vb code take care of it. Thank you.

  4. #4
    Darlene is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    5
    Actually, I figured it out. Once I entered the value in quotes it worked. Is there a way to force the quotes into a person's entry so the user doesn't have to enter them?

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Try:

    Me.textboxname.DefaultValue = """" & InputBox("Enter default value.") & """"
    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.

  6. #6
    Darlene is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    5
    You are my new best friend !! I found that the ending concatenate & was missing - but added it and it works wonderful. Thanks a million.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Ooops! Glad you caught it. And I edited the 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.

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

Similar Threads

  1. Setting default vaulue?
    By djclntn in forum Forms
    Replies: 17
    Last Post: 04-12-2012, 11:20 PM
  2. Setting default value for all records in form
    By robsworld78 in forum Forms
    Replies: 15
    Last Post: 08-14-2011, 12:48 AM
  3. Form Field Default Setting
    By roofbid in forum Programming
    Replies: 3
    Last Post: 12-17-2010, 10:53 AM
  4. Replies: 1
    Last Post: 11-01-2010, 06:59 PM
  5. Setting the Default Value and Proper Case Example
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 08-27-2010, 07:43 PM

Tags for this Thread

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