By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,269 Members | 1,561 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,269 IT Pros & Developers. It's quick & easy.

Run Time error 2001???

P: 26
Hi,

I have a form called Customer and another form called Loan..
the Loan Details has to be entered every month until it is closed.

I have designed a form such that, the user goes to the particular customer record and click a button (Enter Loan) to add the new loan information for the current month.

When he clicks the button, it gets the last value entered for the field Loan Amount and store it into the form for new Loan Information.


Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdEnterLoan_Click()
  2.  
  3.     DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
  4.  
  5.     DoCmd.OpenForm "frmLoanInfo"
  6.     DoCmd.GoToRecord , , acNewRec
  7.  
  8.   Dim id As Integer
  9.  
  10.   id = DMax("LoanID", "tblLoanInfo", "LoanNumber=LoanNumber")  (I am getting the 'id' value but the next statement is where i am getting Run Time Error 2001:You cancelled the previous Operation )
  11.  
  12.   Forms!frmLoanInfo!LoanAmount.Value =  DMax("LoanAount", "tblLoanInfo", "LoanID = id")
  13.  
  14. Exit_EnterJobLabel_Click:
  15.     Exit Sub
  16.  
  17. Err_EnterJobLabel_Click:
  18.     MsgBox Err.Description
  19.  
  20. End Sub
Can anyone help me and tell me where i went wrong?

thanks in advance

Asle
Sep 6 '07 #1
Share this Question
Share on Google+
2 Replies


JKing
Expert 100+
P: 1,206
Try changing the offending line to this:

Expand|Select|Wrap|Line Numbers
  1. Forms!frmLoanInfo!LoanAmount.Value =  DMax("LoanAmount", "tblLoanInfo", "LoanID = " & id)
  2.  
You had spelt the field LoanAmount wrong im assuming and you need the variable id to be concatenated to the criteria string rather than inside it.
Sep 6 '07 #2

P: 26
Try changing the offending line to this:

Expand|Select|Wrap|Line Numbers
  1. Forms!frmLoanInfo!LoanAmount.Value =  DMax("LoanAmount", "tblLoanInfo", "LoanID = " & id)
  2.  
You had spelt the field LoanAmount wrong im assuming and you need the variable id to be concatenated to the criteria string rather than inside it.
Thanks for your reply.

I have tried your code but I am getting the Loan Number for the Maximum LoanID from tblCustomer.

But what i wanted to get is the Last entered value for particular Loan Number.

Say for example, in 'frmLoan' for August, the Loan Balance = $10000.

when i enter info for September, I want $10000 to be entered in the field CurrentLoanAmount. Which then helps me to enter other infor easily.

I used Max function hoping that i would get the LoanBalance value for that LoanNumber based on LoanID. but its not getting me the result.

Need your assitance.

thanks
Asle
Sep 7 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.