Solved

Runtime error 2465 - Application defined or object defined error.

Posted on 2004-04-21
6
1,249 Views
Last Modified: 2010-08-05
When I create a customised rates for customer Fred, and delete one of the rates
Eg Hanoi, Vietnam Parcel
Then come to select that same rate. It brings up an application error. Saying
Runtime error 2465 - Application defined or object defined error.

The debug points too the line in the formcode that says..
MsgBox "No rates for Customer " & Me.Form.CName & ", Rates must be created in Customer Form"

In other words, it doesn’t show the message above as expected. Any clues?
thanks

0
Comment
Question by:elusivesoul
6 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 10878081
Are you working on an mde or mdb?
If it is an mdb can you post the codes for selection of rate, or better all the codes related to this problem.
0
 
LVL 65

Assisted Solution

by:rockiroads
rockiroads earned 100 total points
ID: 10878132
1. Does CName exist as a control on the form?
2. Why do Me.Form.CName, if and when CName is on the same form as what you are using, you can just do Me.Cname

(if you do Me. then CName should come up, if not then Cname does not exist, hence error)


0
 

Author Comment

by:elusivesoul
ID: 10878672
its an mdb file,,,,


Private Sub NewCalc()
lngIncrements = 0
fWeightDifference = 0
fShipRate = 0

strSQL = "SELECT * FROM tblCustomersRates_PubRates_Trans WHERE CRPR_IDSillyCust = " & Forms!frmCustomers!CustID & _
              " AND CRPR_IDZoneRate = '" & Me.txtZone & _
              "' AND PkgType = '" & Me.txtPkgType & _
              "' And Active = -1" & _
              " ORDER BY Weight1 DESC;"
Set DB = DBEngine(0)(0)
Set rs = DB.OpenRecordset(strSQL)

If rs.EOF And rs.BOF Then ' we have NO records
    MsgBox "No rates for Customer " & Me.Form.CName & ", Rates must be created in Customer Form"
    GoTo Exit_cmdCalculate_Click
Else
    rs.MoveLast
    iRecCount = rs.RecordCount
    rs.MoveFirst
End If

Do Until rs.EOF
    Me.txtWt1 = rs!Weight1
    Me.txtRate1 = rs!Rate1
    Me.txtWt2 = rs!Weight2
    Me.txtRate2 = rs!Rate2
    Me.txtSurcharge = rs!Surcharge
    fWeightDifference = Weight - Me.txtWt1

    If Weight >= rs!Weight1 Then
        If Weight > rs!Weight1 Then
            lngIncrements = 1
            fShipRate = rs!Rate1 + rs!Rate2 + rs!Surcharge
                Do Until fWeightDifference <= rs!Weight2
                    lngIncrements = lngIncrements + 1
                    fWeightDifference = fWeightDifference - rs!Weight2
                    fShipRate = fShipRate + rs!Rate2
                Loop
                fExtraCharge = lngIncrements * rs!Rate2
            Me.txtExtra = Format(rs!Rate2, "$0.00") & " x " & lngIncrements & " = " & Format(rs!Rate2 * lngIncrements, "$0.00")
            Exit Do
        Else
            fShipRate = rs!Rate1 + rs!Surcharge
            Exit Do
       End If
    Else
        fShipRate = rs!Rate1 + rs!Surcharge
        'Me.txtExtra = 0
    End If
    rs.MoveNext
Loop

    Me.txtSubTot = fShipRate

If Me.txtDiscount <> 0 Then
    fShipRate = fShipRate - (fShipRate * txtDiscount)
End If
    Me.txtDiscount = [Forms]![frmCustomers]!Discount
    Me.txtWt1.Requery
    Me.txtRate1.Requery
    Me.txtWt2.Requery
    Me.txtRate2.Requery
    Me.txtExtra.Requery
    Me.txtSubTot.Requery
    Me.txtSurcharge.Requery
    Me.txtDiscount.Requery

Me.txtTotalCost = fShipRate

Err_cmdCalculate_Click:
    If Err.Number = 20 Or Err.Number = 0 Then
    Exit Sub
    Else
    MsgBox "Can't find rate.  This rate does not exist in the Customized Rates table.", vbInformation + vbOKOnly, "Add Rate"
    End If
    Resume Exit_cmdCalculate_Click
   
Exit_cmdCalculate_Click:
    Exit Sub

End Sub
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 10878804
  MsgBox "No rates for Customer " & Me.Form.CName & ", Rates must be created in Customer Form"
-------------------------------------------^^^^^^^^^^^ change to Me.CName

Is Cname a control on your form?  as rockiroads have pointed out.
0
 
LVL 11

Accepted Solution

by:
Mighty_Silly earned 400 total points
ID: 10885205
ES,

If the code is in the subform, and the field referred to in you code is on the Main form, then you need to refer to it in correct syntax...

Me.MainForm.Cname

That should work.

-Silly-

:')-
0
 

Author Comment

by:elusivesoul
ID: 10885579
Yep, you were right silly, it was actually on a subform. Thanks for that. Much appreciated guys.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question