Results 1 to 12 of 12
  1. #1
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Use only the Enter button (Access 2000)

    in my subform, when i choose the products with which to make invoice,i choose the products
    from the combo box "productid".After that i go to the control cartons where i choose the humber.And then ,from the control "cartons" i go to a new record with :
    DoCmd.GoToControl "productid"
    DoCmd.GoToRecord , , acNext

    I want to make the user use only the Enter button and not to click on the control productid
    in order to choose another product.
    Is it posible ?

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

    Re: Use only the Enter button (Access 2000)

    Sorry, I don't understand. Where is the focus when you want the user to be able to press Enter?

  3. #3
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Use only the Enter button (Access 2000)

    Thank you for your reply.I am attaching an example in order to explain what i want.
    Let us supose i choose for the first time the product apples.sometimes the user makes
    a stupid step and does not enter cartons, or just clicks on the next line and chooses melons.
    Sometimes Access issues a mistake for that case, but not always and the user manages to choose
    melons while the cartons for the apples are empty.
    Also,another possibility.The user has chosen 1 carton for the appples, then chooses melons, but then
    changes his mind and decides to go back and up and choose 2 cartons for appples.In this case, if the user does not click Enter,

    the invoice will be issues for 1 cartons instead of 2.The correction will not be taken into acount.

    So what i want is to make the user use only he Enter button and not click on the control productid.
    I am very grateful for your help.

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

    Re: Use only the Enter button (Access 2000)

    I don't think you can do this. Instead, create a Before Update event procedure for 'Forder details extended':

    Private Sub Form_BeforeUpdate(Cancel As Integer)
    If Not IsNull(Me.ProductID) And (IsNull(Me.cartons) Or Me.cartons = 0) Then
    MsgBox "Please enter a number of cartons.", vbExclamation
    Me.cartons.SetFocus
    Cancel = True
    End If
    End Sub

  5. #5
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Use only the Enter button (Access 2000)

    Thank you for the reply.
    I am sorry to hear Acces cannot handle this case.The case is when the user changes his mind
    goes back and changes the number of the cartons.Then he goes down again, but the AfterUpdate event is not triggered
    and in that case the proramme does not calculate right,, i.e. does not multiply the new quantity with the unit price.
    The point is ,and i need to trigger the after update event again if the customer changes the number, for example from 1 to 2.
    The easiest way if to use the Enter button,but i want to handle a special stupid case when the user does not use the enter

    button.I have heard of the Dirty even, can we apply it here ? is it possible for Access to know that somebody has
    changed an already entered value?

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

    Re: Use only the Enter button (Access 2000)

    If the user changes the value of the cartons control, the Before Update and After Update events of the control will run, and when (s)he moves to another record, the Before Update and After Update event of the form will run.

  7. #7
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Use only the Enter button (Access 2000)

    Dear Hans


    I am writing to you under this thread since i consider my problem to fall under here.
    Also,in order to help me i will need to explain in more detail the problem.My problem is that the combo box allows the possibility to choose another product for which i have already chosen quantity.In that case
    i cannot update the available stock.I will give an example.
    My warehouse consists of 30 melons and 30 appples
    Suppose i have chosen the product melons.I have in stock 30 melons.
    Then i go the control cartons and choose 1 melon.After updating i have 29 melons.
    Then i click on the same row where the melon is, and choose apples.I have again 30 apples on stock.
    I enter 1 apples, update the row and then i get 29 apples on stock.
    The result is then 29 apples and 29 melons.
    But this is not true, i must have 30 melons and not 29,since i changed my mind.aND THE INVOICE WILL BE
    FOR 1 APPLE ONLY
    This error occurs quite often.Could you help me solve this problem ?

    For those cases when the user wants to delete the product already chosen with a quantity, i have foreseen
    a double click event under the control cartons.In that case the quantity is at first increased in the stock and then deleted.
    Is it possible to forbid chosing again from the combo box ProductID if the product has already updated the quantity ?

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

    Re: Use only the Enter button (Access 2000)

    Where is the current stock stored, and how is it adjusted when a customer orders something? The After update event of the cartons control contains a call to a procedure or function SetBranches, but that is not present in the database you attached.

  9. #9
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Use only the Enter button (Access 2000)

    Thank you so much for your reply.The current stock is stored in the table products.I am sending the db again since i overlooked the module, i had
    to simplify it for the present purpose.
    Thank you for the attention you have given to my question

  10. #10
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Use only the Enter button (Access 2000)

    May be if i manage to differentate between old and new values and then forbid choosing from the
    combo box ? i mean something like if Me.NewRecord=False then ?
    I will appreciate very much your help in this respect

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

    Re: Use only the Enter button (Access 2000)

    In the first place, I wouldn't update the value of branch in the products table in the After Update event of cartons. If you do so, each time the user changes the value, cartons will be deducted from branch. Instead, I would update branch in the Before Update event of the subform. That way, the user can change the product and the number of cartons as many times as he likes before moving to a new record.
    You could disable editing existing records in the On Current event of the subform.

    Note: the code in the Form_BeforeUpdate event replaces that in cartons_AfterUpdate.

    Private Sub Form_BeforeUpdate(Cancel As Integer)
    Dim strSQL As String
    If Not IsNull(Me.ProductID) And (IsNull(Me.cartons) Or Me.cartons = 0) Then
    MsgBox "Please enter a number of cartons.", vbExclamation
    Me.cartons.SetFocus
    Cancel = True
    End If
    DoCmd.SetWarnings False
    strSQL = "UPDATE Products SET branch = branch - " & Me.cartons & _
    " WHERE ProductID=" & Me.ProductID
    DoCmd.RunSQL strSQL
    DoCmd.SetWarnings True
    Me.Quantity = Me.cartons * Me.pack
    Me.liters = Me.Quantity * Me.size
    Me.extendedprice = Me.Quantity * Me.UnitPrice
    End Sub

    Private Sub Form_Current()
    Me.AllowEdits = Me.NewRecord
    End Sub

    By the way, quantity, liters and extendedprice are calculated values, you don't need them in the table.

  12. #12
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Use only the Enter button (Access 2000)

    Dear Hans,

    My problems solved,i need to thank you once gain for the help i have received
    to all my questions.
    My sincere regards

Posting Permissions

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