Results 1 to 15 of 15
  1. #1
    4 Star Lounger
    Join Date
    Aug 2001
    Location
    London, UK
    Posts
    516
    Thanks
    0
    Thanked 0 Times in 0 Posts

    default property (access2000)

    How do I set the default property of a feild to be equal to another feild?
    for example, if I want the ref no to be equal to feild1, should I say =feild1 in the default property of that feild in the table design?

    I also want to know if I could put a formulae to calculate a value in the feild of the table design?

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: default property (access2000)

    Hi,
    Can you give a bit more detail as to what you're trying to do? It's generally not good practice to store calculated values in this way because it's unnecessary (you can simply calculate the value whenever you need it) and it's a pain to make sure that the values are updated when whatever they depend on is updated.
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    4 Star Lounger
    Join Date
    Aug 2001
    Location
    London, UK
    Posts
    516
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: default property (access2000)

    Hi Rory!
    I just wanna multiply price by quantity and store it in a feild called total.
    Im using a form to input data.
    I also want to know if I could assign a feilds value to another feild.

    Thanx

  4. #4
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: default property (access2000)

    Hi,
    That's exactly the type of thing you don't store! You can use code on your form to assign the calculated value to a bound control but there's no point. Whenever you need to use it (e.g. in a query) you simply calculate it. That way you don't have to worry about people changing the quantity or price and having to ensure that your total gets updated.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  5. #5
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: default property (access2000)

    You can set up the forms and queries in such a way that he/she won't know it isn't stored! If you're supposed to maintain the database then you should be allowed to set it up properly!
    Anyway, enough ranting. If you have to store it, you would need to put code into the AfterUpdate event of each field used in the calculation to set the Total field to the correct value - you'll have to do this on the data entry form, not the table.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  6. #6
    4 Star Lounger
    Join Date
    Aug 2001
    Location
    London, UK
    Posts
    516
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: default property (access2000)

    But I have to store this data coz that is how my boss wants it.

    How can I assign a data from one feild to the other? Do I put the following code in the feilds default property : =[feild1]?

    NO WORRIES!
    I figured it out, Im using a query.
    THANX RORY!

  7. #7
    4 Star Lounger
    Join Date
    Aug 2001
    Location
    London, UK
    Posts
    516
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: default property (access2000)

    What code should I put in the after update event?
    I thought I fixed it but it didn't save the value in the table so I guess I haven't fixed it after all.
    <img src=/S/sad.gif border=0 alt=sad width=15 height=15>

  8. #8
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: default property (access2000)

    Something like:
    Me!txtTotal = Me!txtQuantity * Me!txtPrice
    You need to have the txtTotal control bound to the Total field in the table.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  9. #9
    4 Star Lounger
    Join Date
    Aug 2001
    Location
    London, UK
    Posts
    516
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: default property (access2000)

    Still doesn't save the value to the table

  10. #10
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: default property (access2000)

    Hmm, odd.
    1. Are you getting any errors?
    2. Does the txtTotal control on the form display the correct amount?
    3. Is the txtTotal control bound to the Total field in the table?
    Regards,
    Rory

    Microsoft MVP - Excel

  11. #11
    4 Star Lounger
    Join Date
    Aug 2001
    Location
    London, UK
    Posts
    516
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: default property (access2000)

    1. No I'm not getting any error messages
    2.I thought the calculation was working but IT SEEMS THAT IT IS NOT, I designed the form based on a query and it had the calculation, The code you gave me is not working.
    3. When you say bound, do you mean the control source of the table, right? if yes then it is.

    The following is the code I've got behind the AfterUpdate event of the feild moneyspot

    Private Sub moneyspot_AfterUpdate()
    Me!moneyspot = Me!q * Me!tp
    End Sub

    PLEASE HELP

  12. #12
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: default property (access2000)

    Hi,
    You actually want that code in the afterupdate events of the other two controls (q and tp) - that way, if either of those are changed, the moneyspot total is updated too.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  13. #13
    4 Star Lounger
    Join Date
    Aug 2001
    Location
    London, UK
    Posts
    516
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: default property (access2000)

    Works fine!
    THANK YOU!
    <img src=/S/bow.gif border=0 alt=bow width=15 height=15>

    Another help if you don't mind.
    How do I assign the same value of a feild to another feild in a record?

  14. #14
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: default property (access2000)

    Much the same principle, but why on earth would you want to? Storing calculated values I can sort of understand, but storing exactly the same value in 2 fields makes no sense at all to me!
    Regards,
    Rory

    Microsoft MVP - Excel

  15. #15
    4 Star Lounger
    Join Date
    Aug 2001
    Location
    London, UK
    Posts
    516
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: default property (access2000)

    I know but Im doing what I was asked to do,
    THANX RORY
    <img src=/S/fanfare.gif border=0 alt=fanfare width=31 height=23>

Posting Permissions

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