Results 1 to 12 of 12
  1. #1
    Join Date
    Jan 2004
    Posts
    44

    Unanswered: Calculating months & percentages

    Hi there,

    I have a form where figures are entered into text boxes. I have to add 1% percent onto a total figure every month. I was thinking of just calculating the date entered more than 31 days and then minusing the 1 percent but then I realised that it may not be 31 days depending on when the original figure was entered.

    Are there any super duper access gurus who can help me with this.

    Much appreciated

    Smilla

  2. #2
    Join Date
    Jan 2004
    Location
    Islamabad, Pakistan
    Posts
    97

    Re: Calculating months & percentages

    Originally posted by Smilla
    Hi there,

    I have a form where figures are entered into text boxes. I have to add 1% percent onto a total figure every month. I was thinking of just calculating the date entered more than 31 days and then minusing the 1 percent but then I realised that it may not be 31 days depending on when the original figure was entered.

    Are there any super duper access gurus who can help me with this.

    Much appreciated

    Smilla
    You'll have to work with some intermediate level programing and functions to achieve what you want...
    for some reference you can check (http://support.microsoft.com/default...kb;EN-US;88657)

  3. #3
    Join Date
    Jan 2004
    Posts
    44
    Thanks, i have another question,

    If a user enters a date into a date field, how can I save those values into variables.

    i.e. 14/04/03

    day = 14
    Month = 04
    Year = 03

    I could then calculate it from that.

    Sorry I haven't explained myself very well but I hope you understand.

    Thanks

  4. #4
    Join Date
    Jan 2004
    Location
    Islamabad, Pakistan
    Posts
    97
    Originally posted by Smilla
    Thanks, i have another question,

    If a user enters a date into a date field, how can I save those values into variables.

    i.e. 14/04/03

    day = 14
    Month = 04
    Year = 03

    I could then calculate it from that.

    Sorry I haven't explained myself very well but I hope you understand.

    Thanks
    use

    dayvalue = day(txtdate)
    monthvalue = month(txtdate)
    yearvalue = year(txtdate)

    for obtaining day, month and year from a date but if you entered the date as text and not as a date/time filed then use

    dayvalue = day(cdate(txtdate))
    monthvalue = month(cdate(txtdate))
    yearvalue = year(cdate(txtdate))

    as cdate() converts the text to datetype - you can use weekday(datevalue) funtion to check which day of the week as sunday, monday ...

    check Access help for further explanation of these date functions

    - I hope this will help

  5. #5
    Join Date
    Jan 2004
    Posts
    44
    This is my code

    Dim dayvalue As Integer
    Dim monthvalue As Integer
    Dim yearvalue As Integer
    Dim txtdate As Integer

    dayvalue = day(txtdate)
    monthvalue = month(txtdate)
    yearvalue = year(txtdate)

    MsgBox "today is " & dayvalue & "/" & monthvalue & "/" & yearvalue, vbCritical (testing purposes only)

    The date is completely different to what I type in the date field

    Where am i going wrong

  6. #6
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Originally posted by Smilla
    This is my code

    Dim dayvalue As Integer
    Dim monthvalue As Integer
    Dim yearvalue As Integer
    Dim txtdate As Integer

    dayvalue = day(txtdate)
    monthvalue = month(txtdate)
    yearvalue = year(txtdate)

    MsgBox "today is " & dayvalue & "/" & monthvalue & "/" & yearvalue, vbCritical (testing purposes only)

    The date is completely different to what I type in the date field

    Where am i going wrong

    If you have a text box called txtdate then it should work when you ommit the DIM txtdate As Integer statement

  7. #7
    Join Date
    Jan 2004
    Posts
    44
    i dont have a textbox with that name.

    The value of my msgbox which is the values I am pulling from the date entered is always coming up as 30/12/1899.

    Why is it not pulling the correct values from the date I am entering. Do I have to format the date first

  8. #8
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Where do you fill the variable txtdate in your code?
    Your Dim statement tells, it is an Integer.

    The function Year takes a date as its argument.

  9. #9
    Join Date
    Jan 2004
    Posts
    44
    I want to get the values of day, month & year that I have entered into a date field text box.

    For instance, i type in 12 Dec 2003, i want the day value to pick up 12, the month value to pick up the 12 and year value to pick up 2003 or 03.

  10. #10
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    I created a small mdb for you it makes what you want
    Attached Files Attached Files

  11. #11
    Join Date
    Jan 2004
    Posts
    44
    thanks for that, i have managed to get the values of the date entered now but what if I want to calculate another field on a monthly basis

    For instance,

    Date I entered is 29/01/04

    in months time i.e. 29/02/04 and thereafter I would like to add 25 to a purchase value. (which is another field)

  12. #12
    Join Date
    Jan 2004
    Posts
    44

    Calculations by month in a query

    I need to change the value within a table on a month basis. I can do this though a query, can't i. Where can I write the code which works out whether a month has passed?

    Any ideas would appreciated

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •