You can't assign a value to this object Error!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Constantine AI
    New Member
    • Mar 2008
    • 129

    You can't assign a value to this object Error!

    Hi i have created a Sales Order Header with a Sales Order Line (1 to many relationship) See Picture for image of error! I receive this error when inputting data into the sfrmSOHeader in Add mode. I get this error then i can input data like normal. I dont know why i receive this error but i must get rid of it. The control is not read only, or design-view and definately not too large.

    Here is the sfrmSOHeader On Current Code;

    Code:
        Dim ParentDocName As String
    
        On Error Resume Next
        ParentDocName = Me.Parent.Name
    
        If err <> 0 Then
            GoTo Form_Current_Exit
        Else
            On Error GoTo Form_Current_Err
            Me.Parent![sfrmSOLine].Requery
        End If
    
        DoCmd.SetWarnings False
        
        If Me.OrderStatus.Value = -1 Then
            Me.Form.AllowAdditions = False
            Me.Form.AllowDeletions = False
            Me.Form.AllowEdits = False
            Me.cmdDeleteHeader.Enabled = False
            Me.cmdProcessHeader.Enabled = False
            Me.cmdSave.Enabled = False
            [Forms]![frmCustomerOrderForm]![cmdImportCSVFile].Enabled = False
            [Forms]![frmCustomerOrderForm]![cmdAddNewItem].Enabled = False
            [Forms]![frmCustomerOrderForm]![sfrmSOLine].Form.AllowAdditions = False
            [Forms]![frmCustomerOrderForm]![sfrmSOLine].Form.AllowDeletions = False
            [Forms]![frmCustomerOrderForm]![sfrmSOLine].Form.AllowEdits = False
            [Forms]![frmCustomerOrderForm]![sfrmSOLine]![cmdDeleteRec].Enabled = False
        Else
            Me.Form.AllowAdditions = True
            Me.Form.AllowDeletions = True
            Me.Form.AllowEdits = True
            Me.cmdDeleteHeader.Enabled = True
            Me.cmdProcessHeader.Enabled = True
            Me.cmdSave.Enabled = True
            [Forms]![frmCustomerOrderForm]![cmdImportCSVFile].Enabled = True
            [Forms]![frmCustomerOrderForm]![cmdAddNewItem].Enabled = True
            [Forms]![frmCustomerOrderForm]![sfrmSOLine].Form.AllowAdditions = True
            [Forms]![frmCustomerOrderForm]![sfrmSOLine].Form.AllowDeletions = True
            [Forms]![frmCustomerOrderForm]![sfrmSOLine].Form.AllowEdits = True
            [Forms]![frmCustomerOrderForm]![sfrmSOLine]![cmdDeleteRec].Enabled = True
        End If
    And this is the cmdNewOrderNo Button On Click Code;

    Code:
        'Sets the sfrmSOHeader.AllowDetails to True and the Visibility of Fields to True / False
        'Sets sfrmSOHeader to move to NewRecord
        Me.sfrmSOHeader.Form.AllowAdditions = True
        Me.sfrmSOHeader.Form.AllowDeletions = True
        Me.sfrmSOHeader.Form.AllowEdits = True
        [Forms]![frmCustomerOrderForm]![sfrmSOHeader].Visible = True
        [Forms]![frmCustomerOrderForm]![sfrmSOLine].Visible = False
        keybox.Visible = False
        lblOrderLine.Visible = False
        cmdImportCSVFile.Visible = False
        cmdAddNewItem.Visible = False
        cmdGeneratePOrders.Visible = False
        cmdOrderMaintenance.Visible = False
        DoCmd.GoToControl "sfrmSOHeader"
        DoCmd.GoToRecord , , acNewRec
        [Forms]![frmCustomerOrderForm]![sfrmSOHeader]![OrderDate].SetFocus
        'Reset the List lstCustOrderNo Field
        Me.lstCustOrderNo.Value = ""
    The reason for all the AllowAdditions, Edits and Deletions is because one of my requirements is to lock down the Orders when completed. If anyone can suggest how or why i receive this error it would be greatly appreciated!

    p.s. The is more like a nuisance than an actual error but have trie many times to get rid but feel the problem maybe due to the allowadditions, deletions and edits code.
    Attached Files
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    For starters, set a Breakpoint in Line #4 in the Current() Event of the Sub-Form, then Single Step (F8) thought he code, Repeat this process in the Click() Event, if the Error is happening there. This will pinpoint the Line on which the Error occurs. If you do not know how to set a Breakpoint, let me know.

    Comment

    • Constantine AI
      New Member
      • Mar 2008
      • 129

      #3
      Hi i have managed to find the problem, it is to do with my Master and Child Links but haven't managed to fix it yet.

      The Main Form consists of Three Entities; 1 Main Form and 2 Sub-Forms, all which are linked. The Names of the Entities are frmCustomerOrde rForm, sfrmSOHeader and sfrmSOLine.

      The Master and Child Link from CustomerOrderFo rm to sfrmSOHeader is 'CustNo' Key Field. The Master and Child Link from sfrmSOHeader to sfrmSOLine is 'OrderNo' Key Field.

      I have changed the Links to what they should be and its works fine thanks. Origanlly the Links had two references from the CustomerOrderFo rm to the sfrmSOHeader. I had 'CustNo' and 'OrderNo' Fields set as the Master and Child Links. Taking off the OrderNo reference link made it work fine now. Thanks again!

      Comment

      Working...