Solved

Runtime error 2465 - Application defined or object defined error.

Posted on 2004-04-21
6
1,272 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

 
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
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.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

617 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