how to write vb code in access 2007

Version: MSAccess 2007

I have 3 fields in my database that contain currency.
Field 1: PrincipleAmount
Field 2: AmountPaid
Field 3: AmountDue

I have added a Command Button (cmdCalc) to the form.
I need to write code that Subtracts Field2 from Field1 and returns the 
Balance in Field 3.

I have no idea on how to gain access to and how to write code in MSAccess 
2007.
I can do this in VB6.

Thanking You in Anticipation
Julian
0
Utf
12/15/2009 12:29:01 PM
access.modulesdaovba 1670 articles. 0 followers. Follow

2 Replies
1257 Views

Similar Articles

[PageSpeed] 35

On 15 dec, 13:29, tjbvo <tj...@discussions.microsoft.com> wrote:
> Version: MSAccess 2007
>
> I have 3 fields in my database that contain currency.
> Field 1: PrincipleAmount
> Field 2: AmountPaid
> Field 3: AmountDue
>
> I have added a Command Button (cmdCalc) to the form.
> I need to write code that Subtracts Field2 from Field1 and returns the
> Balance in Field 3.
>
> I have no idea on how to gain access to and how to write code in MSAccess
> 2007.
> I can do this in VB6.
>
> Thanking You in Anticipation
> Julian

You do not need Field 3 in your database. Fields like these only cause
corrupt data (in case you forget to push the button).
If you want to show the amount dua in e.g. a query just make an
calculeted field in the query: PrincipleAmount - AmountPaid.

Groeten,

Peter
http://access.xps350.com
0
xps35
12/15/2009 12:41:08 PM
You don't need the command button or any VBA code to do what you want.  

Select the text box where you want the result of the calculation and display 
the Properties Dialog box.  Locate the  Data Tab and then locate the "Control 
Source" property.  In that row type:

= [NameOfFirstTextBox] - [NameOfSecondTextBox]

Just be sure to supply the actual names of the controls that will supply the 
values to be calculated.  

-----
HTH
Mr. B
http://www.askdoctoraccess.com/
Doctor Access Downloads Page: 
http://www.askdoctoraccess.com/DownloadPage.htm


"tjbvo" wrote:

> Version: MSAccess 2007
> 
> I have 3 fields in my database that contain currency.
> Field 1: PrincipleAmount
> Field 2: AmountPaid
> Field 3: AmountDue
> 
> I have added a Command Button (cmdCalc) to the form.
> I need to write code that Subtracts Field2 from Field1 and returns the 
> Balance in Field 3.
> 
> I have no idea on how to gain access to and how to write code in MSAccess 
> 2007.
> I can do this in VB6.
> 
> Thanking You in Anticipation
> Julian
0
Utf
12/15/2009 1:01:02 PM
Reply:

Similar Artilces:

Excel automation to access a workbook
I want to utililze Excel Automation to obtain properties from an Excel workbook. Given path of the Excel workbook, how can I get the properties of a workbook without making the Excel application or the workbook visible. Then obviously close the Excel workbook and the Excel Object after I get the properties Any help with this would be appreciated Here is some code I am using. I need help getting it to work. When I run it, I get an error message "Run-time error '-2147417851 (80010105)' Method 'Open' of object 'Workbooks' failed" I am in a form in Acc...

Intercept ShutDown Event in C# ? Problem with error code 0xC000014
Hi all, I am trying to write application which will intercept ShutDown event and then cancel that even do some backup work and then fire again shut down event. The problem I am facing is that after capturing shutdown event following line does not help me to cancel it completlly: System.Diagnostics.Process.Start(@"C:\WINNT\system32\shutdown.exe", "-a"); So ShutDown seems to be canceld but my application report error code 0xC0000142 in User32.dll, and can not proceed with backup operation. Is there any way to cancel shutdown event and that application have a...

Need access advise regarind linked versus imported tables
I have designed an application that uses a linked csv file as the main table. The reason for this is because another user creates this file and jsut puts it into a designated folder on their computer. Here is the issue. The csv file contains approximately 20K records. I cannot create any type of index on a linked file. Am I better off importing the file into access (or reading the linked table and inserting them into another table with an index)? Is there an easy way to perform something like this? Will this increase performance? I am pretty new to access and am looking for any and all...

What rights to assign to gain login (user access error after incidentally removing some AD rights)
Hi, in our demo environment, one of the demo users in MSCRM (sales, "central region") somehow has been a little bit "crippled" in AD, but not disabled. Nor has it been disabled in CRM. I reassigned all rights in AD, taking one of the other users ("western region") as an example. In MSCRM, the user still looks fine and has never been deactivated. I still get a "user access error" when logging into CRM (online). 1. What are the crucial points/rights to gain access in CRM? 2. If I delete the user and create one (even with same name), all existing tasks/ob...

Using SQL in MS Access 2000
I am trying to run some SQL script in MS Access 2000 for creating query. But its not take 'IF' and 'ELSE' command. Can someone guide me that how can I use IF and Else in MS Access 2000. Kind Regards, Muhammad Hasnain Raja You can't use If and Else in Access SQL. However, the IIf function is the equivalent. IIf(expr, truepart, falsepart) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) <mhraja@gmail.com> wrote in message news:1185887004.782732.108410@k79g2000hse.googlegroups.com... >I am trying to run some SQL script in MS ...

Need help writing an update query
I'm not good at this so I need some help. Here's what I want to do. I have two tables with fields that need linked to add an update. To show what I want to do I have put the table and fields in brackets. Thanks. Here it is: If [Status Table:Status=Sold or No Bid] and [Status Table:Date=1/11/2008] then in [List Table:Publication Fee] enter [$30.00] On Tue, 22 Jan 2008 17:23:17 -0800, Rick <Rick@discussions.microsoft.com> wrote: >I'm not good at this so I need some help. Here's what I want to do. I have >two tables with fields that need linked to add a...

accessing outlook data using excel macro
Hey all, I'm very new with all of this, however, my problem is this: I have a bunch of data in excel which I then want to compare to certain "task" fields in outlook (ie. the "Due Date" column in Tasks for example), then update those outlook fields with new data. I was able to do it in an Outlook macro, but not in the Excel macro. I get a "User defined type not defined" error when trying to define a namespace variable as "Outlook.Namespace" Any help would be greatly appreciated. Thanks. ...

Pay Code Inactive for Employee
I must be missing something, but is there a way to inactive a pay code for a particular employee if it no longer applies to that particular employee, but is still used for other employees? Just go to Cards >> Payroll >> Pay Codes and mark the inactive box. -- Charles Allen, MVP "Hutch" wrote: > I must be missing something, but is there a way to inactive a pay code for a > particular employee if it no longer applies to that particular employee, but > is still used for other employees? Thanks. I had mistaken that for setting the employee inactive and no...

Outlook 2007 Accounts
I just moved from Live Mail (LM) to Outlook 2007. I have multiple email addresses that I use. In LM I set up separate accounts and then don't set the option to include this account when sending mail or synchronizing. I do not see that option in Outlook 2007 in the account set up page. First question is, "is this the best way to set up multiple email addresses" & second "is there anyway to not poll the POP3 server for all of these accounts since I'm going to the same mail server account for each one. Send/Receive Group settings (Open main Outlook window...

TAb forms in Access 2007
I am new to using Access 2007 and I would like to be able to split a large table across many forms using tabs as a way of doing it - like a normal filing system. E.g. tab for name, then contact details, training information, etc. I would be extremely grateful if someone could help me out, as I do not see a method in 2007. Barry, With you form open in design view, click on the Design Tab in the ribbon. One of the control selection buttons looks like a tab control. It should be on the right of the Check mark, but the tool tip will tell you. Click on it then click on your form. To...

I can't remove a watermark in Word 2007, suggestions?
I am having difficulty removing a watermark form a document in Word 2007. Any suggestions would be appreciated. Watermarks are anchored to a header. Double-click to activate the header area; you should then be able to select and delete the watermark. -- Stefan Blom Microsoft Word MVP "jdgesq2" <jdgesq2@discussions.microsoft.com> wrote in message news:2887A6E3-9CDA-48E5-903B-01054A185A3C@microsoft.com... >I am having difficulty removing a watermark form a document in Word 2007. > Any suggestions would be appreciated. ...

Open a program and program file from Access VBA
OK. First off, I am wanting to know if this can even be DONE :) I am wanting to program a command button on a form to open another application and then run a file pertaining to that application based on the "part number" value in a field on a form. I know that command buttons can be programmed to open applications using the command button wizard. However, (an this is just my train of thought), can VBA take the value from the part number field, then look into a specified folder (or two) and find the file to open? Any help on this is most appreciated. Thanks :) Yes, VBA can tak...

Microsoft Word Table design in Access 2007
Is there a method for inserting a table (not an access table, but a word table with columns/rows/header, etc...) in a description field in a form or below the description field? I'm creating a database for development business rules and sometimes a business rule needs a table to explain or identify the heirarchy/relationship of items for the rule. I don't want this to link to anything else but the Business Rule ID that I am currently in. Thanks in advance! You could use a memo field but the data will not be separated by grid lines. You would need to add spacing and ...

Word merge code
I have been using this code for a while with Office 2000. I recently moved to Office 2003 and when you click on "OK Merge to Word" MS Word does open up but with a blank document. In other word the merge failed. Does anyone know what changes need to be made for Ofiice 2003 and this code. Thanks Hi Eric I have just looked at Alberts RunWord module and if it opens word ok then it would seem (I may be wrong) that the problem is not with the code. Have you you moved the location of the word docs ? It is prob the onclick action (or other event) you are using. Try this - ...

"Filter for" context menu item for Access 2007
One of my most commonly used commands in previous versions of Access was the "Filter for" command available in the context menu when right clicking a field in a table or query. Is this feature available in Access 2007? The filter by form is not what I want because it requires many more operations to set up for a quick temporary filter than the "Filter for" menu command. I would frequently type SQL statements such as "A or B or C or D" in the "Filter For" filter command in Access 2003 and earlier. ...

Restoring "Sized with Window" option in Excel 2007?
Who knows a trick to restore the "Sized with Window" option in Excel 2007, automatically resizing chart when size of window changes as in Excel 2003? There is no trick. It cannot be done at all. This capability was removed from Excel 2007. - Jon ------- Jon Peltier, Microsoft Excel MVP Peltier Technical Services, Inc. http://PeltierTech.com/WordPress/ _______ "Pim den Hartog" <Pim den Hartog@discussions.microsoft.com> wrote in message news:A8C41604-3F04-4F16-AA32-E5A2B9884375@microsoft.com... > Who knows a trick to restore the "Sized with Window"...

Importing Emails .pst format from 2007 to 2003 version
Hi: Can I do this? Rec'ng error msg. "brgwtrnj" <brgwtrnj@discussions.microsoft.com> wrote in message news:5D967048-A523-4FA8-8088-AD5245003720@microsoft.com... > Hi: > > Can I do this? Rec'ng error msg. > Do NOT use the import/export function to transfer data from one Outlook to another. (Courtesy of Russ Valentine [MVP-Outlook]) Importing an entire PST may well corrupt your profile and may create a ghost PST that you can't close. Importing PST's will lose: 1. Custom Forms 2. Custom Views 3. Connections between contacts and activities 4....

How do we write a letter with office? It is too screwy to do so?
-- THANKS; "RHAB" <rexbahrex@hotmail.com> wrote in message news:44B2B719-5AAC-42E1-9195-62097C4DE77F@microsoft.com... > > -- > THANKS; Eh? Is this real or a wind up? If you can't figure out how to post a question that we can understand and respond with an intelligent answer, then yes. It will be too screwy for you to use. -- JoAnn Paules MVP Microsoft [Publisher] Tech Editor for "Microsoft Publisher 2007 For Dummies" "RHAB" <rexbahrex@hotmail.com> wrote in message news:44B2B719-5AAC-42E1-9195-62097...

Min Max options in Access 2007 adp reports not showing
I have an access adp which I developed in 2003 with sql server 2000. I have with great success developed and deployed this app to run with Access 2003 Runtime. I would like this app to move to the Access 2007 runtime, and most of the testing has gone well and the issues have been minor. One issue remains which my client is being stubborn (and rightfully so) that needs to be addressed. When I open all reports with this statement: DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria or DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria the reports op...

how do i restore slide thumbnail view in 2007/2010
I opened a "compatibility mode" presentation in powerpoint 2010 beta, and the slide thumbnail viewer was missing. I have looked everywhere, i believe, and cannot figure out how to restore it. i know its kind of a stupid question, but it was much easier in previous versions, and i am not familiar with this version yet. Help would be greatly appreciated. In article <40832BDC-C0BD-419F-B397-6CC0076389B3@microsoft.com>, Rishi Jain wrote: > I opened a "compatibility mode" presentation in powerpoint 2010 beta, and the > slide thumbnail viewer was...

Install Access 07 when Office 03 installed?
HI - I cannot find a place on the MS site to ask this question, so I am desperately asking it here. My apologies to this board. I have Office SB 03 on Win XP sp 2. Can I purcahse Access 07 and installl it successfully AND continue to use the Office 03 prodcuts successfully. I don't want any problems with the products conflicting. I need Office to work! Where do I ask this question? Thank you very much in advance. Differring versions of both Office & their components can usually be installed without problems, excepting outlook The only problem is usually with shorcuts, or ...

Access 2k code doesn't run under Vista/A2k7
I have a new client who has an Access 2000 database that used to run under Windows 2000 Pro. They have just "upgraded" to Access 2007 under Vista, and the old database stopped working - buttons on forms did nothing. When I first looked at it the problem seemed to be the change to the signature of Docmd.Requery (fewer arguments) so I made the necessary changes and the database compiled. I compiled and tested it on my work system (also Vista, A2k7) and it worked fine. When I copied the db onto the client's machine, it didn't work. I checked that it compiled correctly (it d...

Code for Break on Unhandled Errors
Does anyone have any code for setting the VBA option to "Break on Unhandled Errors" (Access 2000). Thanks! Neil see the SetOption Method topic in VBA Help. hth "Neil" <nospam@nospam.net> wrote in message news:AK9Wi.13090$4V6.3308@newssvr14.news.prodigy.net... > Does anyone have any code for setting the VBA option to "Break on Unhandled > Errors" (Access 2000). Thanks! > > Neil > > "Neil" <nospam@nospam.net> wrote in message news:AK9Wi.13090$4V6.3308@newssvr14.news.prodigy.net... > Does anyone have any code fo...

Expression Calling Public Function In Access 2007
Hello Everyone, I have a perfectly functioning db in 2000-02 and 03. On a calendar form, that lives inside another form, I have all the day buttons OnClick event tied to an expression that points to a public function in the forms code container. Looks like this =ClickMe(11). Code Looks like this: Public Sub ClickMe(ByVal iLabelNum As Integer) DoCmd.Hourglass True Me.Repaint Call SelectDay(("lbl" & CStr(iLabelNum))) DoCmd.Hourglass False Exit Sub In Access 2007 (either in 2002 or converted to 2007), I receive an error: something about "The expression On Click you e...

CRM 4.0
We have set up organization level Mail Merge Templates using XML files and they work great. The issue we have is edit access to these templates. We have specifically set users' security role as follows for Mail Merge Templates: Create: user Read: Parent-Child Write: User Despite these settings,. the users can still edit/save changes these Organizational Templates when they forget to select "Personal" in the Save option. How do we prevent edits to the Organizational level templates from occuring? Is this a bug in the CRM 4.0 or is there another setting that we're mis...