Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

MS Access datasheet form

Posted on 2013-02-06
4
Medium Priority
?
312 Views
Last Modified: 2013-02-07
I have a form that's opening in datasheet view
I can enter additions fine.

But I need to set the DEFAULT value on the new record on ONE of the  textbox to the value if a function

The function name is getHtID

On the fefault value property in the text box I've tried

=getHtID
getHtID

tried with brackets...
No go.

If I hard code it, it grabs it of course.
0
Comment
Question by:lrbrister
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38861056
To make it clearer as to exactly what you have, and what you are doing, please post a sample of this DB


Sample database notes:
1. Back up your database(s).
2. Combine the front and back ends into one database file.
3. Remove any startup options, unless they are relevant to the issue.
4. Remove any records unless they are relevant to the issue.
5. Delete any objects that do not relate directly to the issue.
6. Remove any references to any "linked" files (files outside of the database, Images, OLE Files, ...etc)
7. Remove any references to any third party Active-x Controls (unless they are relevant to the issue)
8. Remove, obfuscate, encrypt, or otherwise disguise, any sensitive data.
9. Unhide any hidden database objects
10. Compile the code. (From the VBA code window, click: Debug-->Compile)
11. Run the compact/Repair utility.
12. Remove any Passwords and/or security.
13. If a form is involved in the issue, set the Modal and Popup properties to: No
    (Again, unless these properties are associated with the issue)
14. Post the explicit steps to replicate the issue.
15. Test the database before posting.

In other words, ...post a database that we can easily open and immediately see and/or troubleshoot the issue.
And if applicable, also include a clear graphical representation of the *Exact* results you are expecting, based on the sample data.

JeffCoachman
0
 
LVL 52

Accepted Solution

by:
Gustav Brock earned 2000 total points
ID: 38863100
One option is to use the OnOpen event:

  Me!txtYourTextBox.DefaultValue = getHtID()

As DefaultValue is a string, you may need this:

  Me!txtYourTextBox.DefaultValue = CStr(getHtID())

/gustav
0
 

Author Closing Comment

by:lrbrister
ID: 38863739
Believe it or not...I noticed the Parantheses on your code and tried that...worked.

Seems that at tomes Access requires them and at other times it doesn't
0
 
LVL 52

Expert Comment

by:Gustav Brock
ID: 38863754
Yes, outside VBA they are mandatory.

/gustav
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question