You haven't declared the first three variables you have used ;
The reason is that the local version of the database has Option Explicit in the definition of the module.Code:Sales_Cost Fisrt_Date_Of_Payment Number_Of_Installments
This is a GOOD thing as it forces you to declare your variables. And would also probably have picked up on the spelling mistake.
DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
Please use the star below the post to say thanks if we have helped !
↓↓ It's down here ↓↓
did you dim Sale_Cost, First_Date_of_Payment, and Number_of_Installments?
Correct.
You need to declare those variables. https://msdn.microsoft.com/en-us/vba...or=-2147217396
I have guessed at the type of data you want to use.Code:Dim Sale_Cost as Currency Dim Fisrt_Date_Of_Payment as Date Dim Number_Of_Installments as Integer
DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
Please use the star below the post to say thanks if we have helped !
↓↓ It's down here ↓↓
Mehvan,
Always include Option Explicit in your modules.
When posting code, please post the entire sub or function.
Yes and as I advised you needed to declare those variables ;
Code:Private Sub CmdInstalAmount_Click() On Error GoTo err_CmdInstalAmount_Click Dim rst As DAO.Recordset Dim i As Integer Set rst = Me.RecordsetClone Dim Sale_cost As Currency Dim Fisrt_Date_of_Payment As Date Dim Number_Of_Installments As Integer Sale_cost = Forms![InstalmentInvoiceF]![InstalmentTotal] Fisrt_Date_of_Payment = Forms![InstalmentInvoiceF]![InstalDate] Number_Of_Installments = Forms![InstalmentInvoiceF]![InstalQy] For i = 1 To Number_Of_Installments rst.AddNew rst![Forms]![SubInstalmentF1]![SubInstalmentID] = Forms![InstalmentInvoiceF]![InstalmentInvoiceID] rst![Forms]![SubInstalmentF1]![Instalment] = i rst![Forms]![SubInstalmentF1]![InstalmentAmount] = Sale_cost / Number_Of_Installments rst![Forms]![SubInstalmentF1]![InstalDate] = DateAdd("m", i - 1, Fisrt_Date_of_Payment) rst.Update Next i rst.Close: Set rst = Nothing exit_CmdInstalAmount_Click: Exit Sub err_CmdInstalAmount_Click: MsgBox Err.Description Resume exit_CmdInstalAmount_Click End Sub
DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
Please use the star below the post to say thanks if we have helped !
↓↓ It's down here ↓↓
I have solved it by using command in SubForm , not in Main from
thanks for all
Glad you solved it.
For future posts it helps to post the actual code (Use the # mark in the editor to preserve its layout), not a picture, and show use the line the error occurs on.
DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
Please use the star below the post to say thanks if we have helped !
↓↓ It's down here ↓↓
thanks a lot
I will do it next time , I didn't know that