If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
addition with in a field
I want to be able to set focus in a field, then enter "3 + 4" and when
hitting "=", the value in that field will be "7" |
#2
|
|||
|
|||
Using the "=" would add a layer of complexity and reduce response time,
because you would have to use either the KeyPress or KeyDown events which will have to evaluate every keystroke. Here is a way that will give you the same results regardless of how the text box (not a field, fields are in tables) is exited: In the after update event of the text box: Me.MyTextBoxName = Eval(Me.MyTextBoxName) You will need to ensure you have an error handler in the event procedure, because if a user enters a value that cannot be evaluated, it will cause an error. "haggr" wrote: I want to be able to set focus in a field, then enter "3 + 4" and when hitting "=", the value in that field will be "7" |
#3
|
|||
|
|||
You will need to provide an unbound text box on your form where the user can
enter the calcuation. In its AfterUpdate event procedure, use Eval() to evaluate the expression, and assign the result to your field. Example: Private Sub txtCalc_AfterUpdate If IsNull(Me.txtCalc) Then Me.[MyField] = Null Else Me.[MyField] = Eval(Me.txtCalc) End If End Sub Note that you will need error handling in case the user enters something that makes no sense--typically error 2431. -- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "haggr" wrote in message ... I want to be able to set focus in a field, then enter "3 + 4" and when hitting "=", the value in that field will be "7" |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Help to merge Image (Doug Robins?) | JohnB | Mailmerge | 21 | June 23rd, 2005 05:28 PM |
Design help, please | SillySally | Using Forms | 27 | March 6th, 2005 04:11 AM |
LOOKUP FOR A VALUE ON A TABLE | Samora | New Users | 9 | February 22nd, 2005 01:06 PM |
Syntax needed to get needed reports | Frank Lueder | New Users | 15 | January 6th, 2005 08:39 AM |
New Record Update | Michelle | Using Forms | 5 | October 28th, 2004 07:59 AM |