Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    2 Star Lounger
    Join Date
    Aug 2005
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    allow edits (Acess 2000)

    I need a help to improve my command button called change of price as shown in my atachment placed in the subform.The function of this button is to allow the user to change the price.
    ususally the corection of the price is forbidden for the user.I use the Set Focus code.Actually the bututton works,but many times it works ony with the first product and ll in all i think the function of the button
    is not well done. Could you advice me how can i change my command, and at what is the best time for the user to click the button?

    Thank you in advance for the help !!

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: allow edits (Acess 2000)

    I don't understand why you move to next and previous records in the code.

  3. #3
    2 Star Lounger
    Join Date
    Aug 2005
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: allow edits (Acess 2000)

    Dear Hans,

    Thank you. you question has shown me the way how to proceed.
    1. I have removed the line 'DoCmd.GoToRecord , , acPrevious

    3. in the afterupdate event of productid i have added: Parent!TglCorrect.Value = 0

    2, in the Afterupdate event of the control unti price i have put the value of the control TglCorrect to 0.
    Then i wanted to go back again to the control cartons but i coudlnt.How can i go back to this control in order to enter
    the quantity of the cartons?




    Private Sub UnitPrice_AfterUpdate()
    Parent!TglCorrect.Value = 0
    DoCmd.GoToControl Me!cartons
    End Sub

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: allow edits (Acess 2000)

    GoToControl expects a name as argument, not an object. You must use either

    DoCmd.GoToControl "cartons"

    or

    Me.cartons.SetFocus

  5. #5
    2 Star Lounger
    Join Date
    Aug 2005
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: allow edits (Acess 2000)

    Now it works and i thank you so much i have my problem solved with your advices and comments.
    This loungs is superb !

  6. #6
    2 Star Lounger
    Join Date
    Aug 2005
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: allow edits (Acess 2000)

    Dear Hans,

    As i have told you the code works perfect.However, in order to simplify the example in the attachmement,i have forgotten to tell you that i have an BeforeUpdate event in my subform.
    This event conflicts with my button Changeprice and i cannot go to the control unit price in order to correct it.On the oher hand the BeforeUpdate event is very useful because it forbids
    the user to go to a new product without having chosen some quantity and without quantity the invoice will have no sense.I do not ant to give up the BeforeUpdate event.
    How could i solve this conflict?I am sending the new atchement

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: allow edits (Acess 2000)

    General remarks:
    <UL><LI>Several tables have duplicate indexes, for example Customers has two indexes on the CustomerID field. Indexes take up space, so you should remove duplicates and unnecessary indexes. Only keep those you really need, such as the primary key.
    <LI>Subdatasheets in tables slow down performance. You should set the Subdatasheet Name property of all tables to [None] instead of [Auto].
    <LI>Establish relationships between the tables and enforce referential integrity. For example, you have no relationship between Products and Order Details on ProductID. There are records in Order Details with invalid ProductIDs. That would not have been possible if you had established a proper relationship.
    Note: you will have to correct the invalid ProductIDs before you create the relationship.
    <LI>Turn off 'Track name AutoCorrect info' in the General tab of Tools | Options... This setting leads to all kinds of problems.
    <LI>Activate the Visual Basic Editor, and select Tools | Options...
    Tick the check box "Require variable declaration", then click OK.
    This will add a line Option Explicit at the top of all NEW modules.
    You should add this line manually to all existing modules.
    It will seem irritating at first, but it will save you a lot of trouble in the long term.[/list]Specific remarks:
    <UL><LI>You have a picture in the Picture property of the subform. Since you display it as a datasheet, the picture isn't used, so it only takes up unnecessary space in the database. Clear the Picture property.
    <LI>You have a lot of superfluous code. For example, there is no need to use both DoCmd.GoToControl and SetFocus for the same control. One of the two is sufficient.
    <LI>You also have a lot of code that is never used. Remove unused code, it only takes up unnecessary space.
    <LI>You have a lot of unnecessarily complicated code. Since the following lines are in the module of Forder details extended:

    Dim ctl As Control
    Set ctl = [Forms]![FOrderInformation]![Forder details extended].[Form]![unitprice]
    ctl = 25

    they can be replaced with

    Me.UnitPrice = 25

    which is both shorter and clearer.
    <LI>Similarly, in the module for FOrderInformation, you don't have to refer to Forms!FOrderInformation, you can use Me instead.[/list]Now to your question. I would throw out all instructions to set focus to other controls and to move to other records. They are very confusing and most of them serve no useful purpose.

  8. #8
    2 Star Lounger
    Join Date
    Aug 2005
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: allow edits (Acess 2000)

    Really i am very grateful.I will copy your answer and will have it as a manual for my improvement of the database
    kind regards

  9. #9
    2 Star Lounger
    Join Date
    Aug 2005
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: allow edits (Acess 2000)

    Dear Hans,


    I am following your advice and gradualy i will inv0lve all your recomendations.
    I have one more question not clear to me about my button Change price.When i click it i get the message
    " you have to fill in either quantity or cartons". This is because of my Before Update event.
    But i need it too. So my question is can i preserve the condition in the Before Update event and at the same time make my

    button "Change price" work? Or as the joke goes, "to eat the cake and have it"?

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: allow edits (Acess 2000)

    You should first throw out all the unneeded code. It should work ok then. See attached version.

  11. #11
    2 Star Lounger
    Join Date
    Aug 2005
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: allow edits (Acess 2000)

    Dear Hans

    Thank you for your reply.Somehow i cannot manage to work with your attachement.I also need all the codes i have.
    I want to ask you the following:Can i restrict the action of the Before update event when i click the control ChangePrice ?
    for example
    If Parent!TglCorrect = true Then
    If IsNull(Me.Quantity) Then
    MsgBox " You have to fill in either quantity or cartons!", vbCritical
    Cancel = True
    DoCmd.GoToControl "productid"
    Exit Sub
    End If
    End If

    I have tried it but without succes.Where i am wrong ?

  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: allow edits (Acess 2000)

    Sorry, I don't understand. Why do you "also need all the codes i have"? Most of the code doesn't do anything useful.

  13. #13
    2 Star Lounger
    Join Date
    Aug 2005
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: allow edits (Acess 2000)

    Obviously it is my fault somewhere since i couldnt change the price with your attachement

    kind regards

  14. #14
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: allow edits (Acess 2000)

    That's strange, I have no problem changing the price in the database I attached.

  15. #15
    2 Star Lounger
    Join Date
    Aug 2005
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: allow edits (Acess 2000)

    do i download the right db? Your db is called DB2.When i choose a product and after that click the button then i get the message from my BeforeUpdate code.Do i have the right database/

    kind regards

Page 1 of 2 12 LastLast

Posting Permissions

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