Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 3rd, 2005, 02:51 AM
Authorized User
 
Join Date: Nov 2005
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default How can we use FORMULAE in Access ??

hello,

  I am using Microsoft Access, and trying to creating one FORM, now what i want to do is, when i suppose to enter data in row, after pressing TAB (to move next column), the entered data shoudl multilplied by 0.001 and replace there itself when i first enter data..

  Any ideas, tell me in brief, am new to ACCESS..

~ ~ ~ There is no Right, There is no Wrong, KNOWLEDGE is Only the POWER ~ ~ ~
__________________
~ ~ ~ There is no Right, There is no Wrong, KNOWLEDGE is Only the POWER ~ ~ ~
 
Old December 3rd, 2005, 11:32 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

One way that you could do it, is to code the function, and run it when the text box loses focus. The problem here is that if you click on the textbox, and then leave it again, it could rerun the function, so you would need to put some code in place to prevent this.

If you have a textbox called txtValue, go to the properties, and click the On LostFocus Event. A button will appear with ... on it. Click on that, choose Code builder, and you will be given something like...

Code:
Private Sub txtValue_LostFocus()

End Sub
Between those two line you would enter the following...

Code:
dim dblValue as double

if isnumeric(txtValue.text) then
    dblValue = val(txtValue.text)
    if dblValue > 0.1 then
        dblValue = dblValue * 0.001
        txtValue.text = dblValue
    end if
else
    msgBox "Not a numeric value!"
end if
That should be fairly straight forward, although it may need a little tweaking, and you could take out the check for the numeric value if you need to. Let me know if need any additional explanation.

Mike



Mike
EchoVue.com
 
Old December 5th, 2005, 01:18 AM
Authorized User
 
Join Date: Nov 2005
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Echovue,

   I have got very much intelligent solution from you, but i m using only Excel..

  Without using VB, how can we do that..??

~ ~ ~ There is no Right, There is no Wrong, KNOWLEDGE is Only the POWER ~ ~ ~
 
Old December 5th, 2005, 01:27 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Forgive me, the original posting specifically said Access. You would typically do something like this is a module attached to an Access Form (it is written in VBA.)

To do this in Excel is a completely different animal, and I would think that you may have more success in the Excel forum.

Sorry I couldn't be more help,

Mike

Mike
EchoVue.com
 
Old December 6th, 2005, 05:27 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 155
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to leehambly
Default

dave,

this isnt excel... the "worksheet"/"datasheet" view isnt like Excel, it just looks like Excel. If you want to use a formula to interact with your data, you should be doing that in the form, report or query that is displaying your data and NOT the table where the data is stored. Depending on your required function you may need to code it, and you may not.

So, you have a form you are trying to create and then you say you have a row... a row of what, exactly?





Similar Threads
Thread Thread Starter Forum Replies Last Post
401.3 Access denied due to Access Control List cforsyth .NET Framework 2.0 8 May 28th, 2009 01:56 PM
Converting Excel formulae to VB James Diamond Excel VBA 3 May 11th, 2004 06:23 AM
ADE file in Access 2000 <---> Access XP ginoitalo Access 3 April 14th, 2004 09:06 PM
Offset Formulae aspadda Excel VBA 3 January 6th, 2004 02:09 PM
Access XP VBA compatibility issues w/ Access 2000 bourgeois02 Access VBA 1 August 19th, 2003 04:14 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.