Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Runtime error 2465 - Application defined or object defined error.

Posted on 2004-04-21
6
Medium Priority
?
1,305 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 400 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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
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 1600 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

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Question has a verified solution.

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

If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

885 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