Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2002
    Posts
    7

    Unanswered: Access 2000 Code error

    OK! So far so good, but one error to clear up.
    I have a form MainAddresses and a form OrgAddresses, when choosing an address from the lngAddressID field on frmOrgAddresses, if an address doesnt exist, I want to Double Click, add it to the main Address table, and my combo box.

    frmMainAddress
    lngAddressID
    txtAddress1
    txtAddress2
    txtCity
    txtState
    txtZip

    frmOrgAddresses
    lngORGADDRESSID
    lngORGID
    lngAddressID
    OrgAddressType

    I put this code in the DblClickEvent of the lngAddressID field:
    Private Sub Combo10_DblClick(Cancel As Integer)

    On Error GoTo Err_AddressID_DblClick
    Dim lngAddressID As Long

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

    Exit_Combo10_DblClick:
    Exit Sub

    It kinda sorta works, if you double click the field you first get

    Error: Object doesn't support this property or method.

    HOWEVER, it will then go ahead, open the MainAddress Form, let you add a new address and updates the Address Table, and the OrgAddress Table accordingly.

    Any help with the bug killing appreciated.

  2. #2
    Join Date
    Apr 2002
    Posts
    7

    Combo box code error

    For anyone who cares to know:
    First I needed to handle how to
    tell the user to double click an address field to add
    a new address:


    Code:
    Option Compare Database
    'Instruction on how to add new data.
    Private Sub Combo10_NotInList(NewData As String, Response As Integer)
        MsgBox "Double-click this field to add an entry to the list."
        Response = acDataErrContinue
    End Sub

    Then I needed the actual code for the combo box,
    which form to open, (Control Name left at Combo10
    here for example.)

    [code]'Code for Combo box.
    Private Sub Combo10_DblClick(Cancel As Integer)
    On Error GoTo Err_AddressID_DblClick
    Dim lngAddressID As Long

    If IsNull(Me![Combo10]) Then
    Me![Combo10].Text = ""
    Else
    lngAddressID = Me![Combo10]
    Me![Combo10] = Null
    End If

    DoCmd.OpenForm "frmMainAddress", , , , , acDialog, "GotoNew"
    Me![Combo10].Requery
    If lngAddressID <> 0 Then Me![Combo10] = lngAddressID

    Exit_Combo10_DblClick:
    Exit Sub

    Err_AddressID_DblClick:
    MsgBox Err.Description
    Resume Exit_Combo10_DblClick
    End Sub
    [\code]

    Then I needed code in the On Load event of the form to be opened. (GoToNew).

    Code:
    'Coded needed in the On Load Event of any form you want to add new data to.
    Private Sub Form_Load()
        If Me.OpenArgs = "GotoNew" And Not IsNull(Me![lngAddressID]) Then
            DoCmd.DoMenuItem acFormBar, 3, 0, , acMenuVer70
        End If
    End Sub

Posting Permissions

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