Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2003
    Location
    Knoxville, TN - USA
    Posts
    27

    Unanswered: Event Procedure - On DBL Click - Open Form - Basic Help

    Greetings Everyone or Anyone,

    What is the best "Event Procedure" code to put in a form's combo box "On Dbl Click" event which will open another form.

    Basically, on frmOrders there is a customer combo box. If the customer is new and does not show up in the combo box list then the user needs to double click on the combo box to open frmCustomers and add the relative data. After closing the frmCustomers the combo box list on frmOrders should now show the newly created customer.

    I tried different variations of the following code but nothings works right:
    DoCmd.OpenForm "frmCustomers", , , , , acDialog, "GotoNew"

    Thanks In Advance,
    Rookie User

  2. #2
    Join Date
    Sep 2003
    Location
    Lancashire, UK
    Posts
    22
    I tried different variations of the following code but nothings works right:
    What exactly doesn't happen that you want to happen

  3. #3
    Join Date
    Mar 2003
    Location
    Knoxville, TN - USA
    Posts
    27

    Thanks for your time Robbo

    Using the following line:

    DoCmd.OpenForm "frmCustomers", , , , , acDialog, "GotoNew"

    It does not open frmCustomers as "GotoNew". Also, after adding the new record and closing frmCustomers the combo box list in frmOrders does not contain the newly added customer. Looks like the combo box needs to be refreshed.

    This is what Iam looking for in English:
    1. Open frmOrders to create a new order
    2. Select the Customer from a combo box list
    3. If Customer is not listed then dbl click on combo box to
    Open frmCustomer, add new, and close frmCustomer
    4. Select the newly added customer in the combo box

  4. #4
    Join Date
    Mar 2003
    Location
    Knoxville, TN - USA
    Posts
    27

    Found an example in a M$ template called Household Inventory

    ---------------------- frmHousehold Inventory - Category Combo Box

    Private Sub CategoryID_DblClick(Cancel As Integer)
    On Error GoTo Err_CategoryID_DblClick
    Dim lngCategoryID As Long

    If IsNull(Me![CategoryID]) Then
    Me![CategoryID].Text = ""
    Else
    lngCategoryID = Me![CategoryID]
    Me![CategoryID] = Null
    End If
    DoCmd.OpenForm "Categories", , , , , acDialog, "GotoNew"
    Me![CategoryID].Requery
    If lngCategoryID <> 0 Then Me![CategoryID] = lngCategoryID

    Exit_CategoryID_DblClick:
    Exit Sub

    Err_CategoryID_DblClick:
    MsgBox Err.Description
    Resume Exit_CategoryID_DblClick
    End Sub



    ---------------------------------------------------- frmCategories

    Private Sub Form_Load()
    If Me.OpenArgs = "GotoNew" And Not IsNull(Me![CategoryID]) Then
    DoCmd.DoMenuItem acFormBar, 3, 0, , acMenuVer70
    End If
    End Sub

  5. #5
    Join Date
    Sep 2003
    Location
    Lancashire, UK
    Posts
    22
    Try
    DoCmd.OpenForm "frmCustomers", , , , acFormAdd, acDialog
    instead. This should ensure the form is opened in data addition mode only

    Set the frmOrders GotFocus event to the following

    Code:
    Private Sub Form_GotFocus()
    
        (Me.)ComboBoxName.Requery
    
    End Sub
    Me. is optional and is added as some people prefer to use it, though Me is the default object for a form and so is assumed by default if omitted.
    ComboBoxName is the name for the Customer Combo Box

    This should ensure that when the focus is passed back to the Order form from the Customer form, the combo box is requeried

  6. #6
    Join Date
    Mar 2003
    Location
    Knoxville, TN - USA
    Posts
    27

    Great Stuff - It Worked - Thanks

    Per your suggestion I used and it worked:
    DoCmd.OpenForm "frmCustomer", , , , acFormAdd, acDialog
    Me.CustomerID.Requery


    In the M$ example they used:
    DoCmd.OpenForm "Categories", , , , , acDialog, "GotoNew"
    Me![CategoryID].Requery


    If it does not take much time, can you give a short breakdown on the difference in syntax between:
    Me.ComboBoxName.Requery
    Me![ComboBoxName].Requery


    Thanks again for your help....

  7. #7
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    Me! is correct
    Me. works

    [name with spaces-and-hyphens] works, without [] it doesnt.

    izy

Posting Permissions

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