Results 1 to 5 of 5
  1. #1
    mulefeathers is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Oct 2009
    Posts
    39

    Performing calculations in the form.

    I have a form that I want to perform some simply math in the form. I could do it a query but this is an unbound form that a user will be using.



    I have six fields on a form. 5 text box and 1 combo box. The combo box populates 2 of the text box. The user will input a quantity in another text box. So I have txtqty and txtpackagecost.

    I want to multiply the 2 togeather and have the answer placed in txttotal.

    I used this code so that when I tab into the field I would get the result however I am only returning $0.00

    Private Sub txttotal_GotFocus()
    Dim txtqty As Integer
    Dim txtpackagecost As Integer
    txttotal = txtqty * txtpackagecost
    End Sub

    What's wrong

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    In the control source of the total put the calculation : =[qty]*[cost]

    in the After Update event of the both the qty and the cost, do a Me![total].Requery

  3. #3
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Try this:

    Code:
    Private Sub txttotal_GotFocus()
    Dim txtqty As Integer
    Dim txtpackagecost As Integer
    txttotal = me.txtqty * me.txtpackagecost
    End Sub
    Need to help Access know that the fields are on the current form.

  4. #4
    mulefeathers is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Oct 2009
    Posts
    39
    I have tried both of these solutions and both work perfect. I am getting another error saying I can't assign a value to Me.txttotal = Null. Other than that it works.

    Thanks for your help.

  5. #5
    mulefeathers is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Oct 2009
    Posts
    39
    Got it Thanks again

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Help with small form calculations
    By Nokia N93 in forum Access
    Replies: 3
    Last Post: 12-06-2011, 06:29 AM
  2. Form/Subform Calculations
    By sidewayzalex in forum Forms
    Replies: 0
    Last Post: 08-15-2011, 01:11 PM
  3. Calculations in a form
    By elmere in forum Forms
    Replies: 3
    Last Post: 04-27-2011, 04:11 PM
  4. Performing count in VBA
    By jgelpi16 in forum Programming
    Replies: 3
    Last Post: 08-21-2010, 07:41 PM
  5. Replies: 14
    Last Post: 06-03-2010, 06:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums