Solved

Runtime error 2465 - Application defined or object defined error.

Posted on 2004-04-21
6
1,226 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 119

Expert Comment

by:Rey Obrero
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 119

Expert Comment

by:Rey Obrero
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

705 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now