DataBase - Variable Pass to new record
Asked By Mohammed
30-Jan-10 10:31 PM
Can somebody help me to pass a variable to one record which is search and
selected.
For Example
on one record I have startCoupon = 101 then add 5 on this StartCoupon then
it will become startCoupon will be 106
Then we search another record and select the record
I want the StartCoupon value automatically show in textbox as 106
Please help me to make it possible.
DefaultValue
(1)
TableName
(1)
DMax
(1)
StartCoupon
(1)
Textbox
(1)
Arvin Meyer [MVP] replied to Mohammed
On the next record, set the DefaultValue property to:
= DMax("FieldName", "TableName")
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Refresh unbound textbox DataBase Refresh unbound textbox Hello, Using Access = 9203 = 85 I have quite a bit of VBA code that runs Between all of the SQL code, I display information to the user in an unbound textbox on the form. Something like this: = 91 = 92 = 92 = 92 = 92 = 92 = 92 = 92 = 92 on some occasions) the queries will run without the text being displayed; i.e., the textbox will display = 93About to run queries = 94 and then will display = 93Finished queries. = 94 I the problem was that the queries ran so fast, I just couldn = 92t see the textbox change, but this happens even when it takes a few moments for the queries to almost like I need to put in a break (like a msgbox) to get the textbox to refresh = 97which works strangely enough? Or possibly to set the focus back to form / textbox? Any thoughts? alex Access Discussions Bit (1) VBA (1) Application (1) DoEvents (1) Otherwise (1 Refresh (1) Textbox (1) Queries (1) Alex Not sure why . . . If this is an intermittent issue, that makes
Keep last entered date on form DataBase I am curious to know if a TextBox on a form can be set to the last date that was in the TextBox. I have this little piece of code that sets the TextBox to the current date. Private Sub TDATE_Click() TDATE.Value = Date End Sub However, as I related dates, for yesterday or two days ago, so I???d like to click the TextBox and have the date be today???s date or if I choose another date, such as yesterday, keep this date in that TextBox, for the next record that I???ll enter, after the current record is entered. Does information was helpful, please indicate this by clicking ''Yes''. Access Discussions ADODB.Command (1) TDATE.DefaultValue (1) TDATE.Value (1) ADODB (1) VBA (1) AdfterUpdate (1) DefaultValue (1) ControlName (1) Basically, you want to have the control default to today's date the Doubleclick event rather than Click - it is much too easy to unintentionally click a textbox. Then set the control's default value in its own AfterUpdate event, to make the
I have a form in which I need to do a default value of one textbox with the value of another textbox. The max warranty txtbox default value should be the contract warranty textbox value. Both fields are bound fields. A majority of time the max will be the to the contract default? Thanks. John Access Forms Coding Discussions VBA (1) John JohnE (1) DefaultValue (1) Default value (1) Warranty (1) Textbox (1) You can not actually use the DefaultValue property for this kind of thing because it is applied at the first keystroke on new records. So by the time the contract warranty textbox value gets a value, it is too late to make use of the DefaultValue property. Try using a little VBA code in the contract warranty textbox's AfterUpdate event
in the expression builder (the only option it will give me). = const cHeight = """" me![Fld37].defaultValue = cHeight&me![Fld37].Value&cHeight It is not working and flashes the following error message 1) Leo Marshall Barton (1) VBA code (1) Marshal (1) Control (1) Microsoft Access (1) DefaultValue (1) You have mixed up the differences between an * *expression* * on a control property and procedure* * with code like you tried to put in the property: Const cHeight = """" Me![Fld37].DefaultValue = cHeight & Me![Fld37] & cHeight - - Marsh MVP [MS Access] But this is what Dave has and use the curent control value for new records, you need to assign it to the defaultvalue of the control. For example something like '* ** ** ** * Code Start * ** ** ** ** * const cQuote = """" 'Thats two quotes me!Control.DefaultValue = cQuote & me!Control.Value & cQuote '* ** ** ** * Code End * ** ** ** ** * Also I made it work by inserting in just typed Dave's VBA code directly into the property. Regardless of all that, the DefaultValue property expects an expression (indicated by the = sign). You are NOT doing that. You should create the expression (which does not really require the = sign) and push it into the DefaultValue property. If you want to set the default value whenever a user manually sets the s Load event. Possibly, you want to do both. control's Value instead of its DefaultValue. Remember that a DefaultValue is only used when a new record is started. It should
sure how to return the value using the SQL statement? DataBase I want set Town.Defaultvalue to query value: Town.DefaultValue = SQL "SELECT TOP 1 JHPclients.County FROM JHPclients GROUP BY JHPclients.County ORDER BY Count statement? Any ideas? Access Forms Coding Discussions Perth Western Australia Tips (1) SQL statement (1) DefaultValue (1) DLookup (1) A SQL statement cannot return a value. You can DLookup() the field right value ("Leics"), but when I start a new record the county field shows County.DefaultValue = DLookup("[county]", "[top county]") MsgBox County.DefaultValue Any thoughts? I dont know why it did not work but I changed it to add the formula rather than the value and it works County.DefaultValue = " = DLookup('[county]', '[top county]')" You need to wrap the value in " characters when setting the DefaultValue: County.DefaultValue = Chr(34) & DLookup("[county]", "[top county]") & Chr(34) - - Ken Snell http: / / www.accessmvp.com / KDSnell