formopen event

sahh1419

Registered User.
Local time
Today, 15:21
Joined
Dec 27, 2012
Messages
29
Respcted,
i have a table name fee. which contains the following fields:
GR No
Date
Month
Year
AdmFee
TutFee
ExamFee
Other
Total
Paid
Balance
.................................................. ...............................................
i want to unpaid records insert into another table when the paid field is equal to: zero(0)
If the 9 record of fee table is unpaid.the following code i have written in form_open event only insert only first record 9 times. but i need to insert the all 9 records insert in that table.
please see the code:
have used this code:
On Error GoTo ErrorHandler
DoCmd.SetWarnings False
Dim StrSQl As String
Dim a As Date
a = Date
Dim D As Integer
D = Day(a)
Dim db As DAO.Database
Set db = CurrentDb
'Set rs = DB.OpenRecordset("feesms")
StrSQl = "Insert into MsgOut (iid,msg,send,msgto) " & _
"SELECT [GR No], 'Respected Parents!Your Child Fees Has Been Due..Please Paid the dues as earliest...', 'Yes', Mobile " & _
"FROM feesms " & _
"WHERE [D] > 10 AND ([paid] = 0 Or [paid] IS NULL)"
db.Execute StrSQl, dbFailOnError
ExitHandler:
DoCmd.SetWarnings True
Exit Sub
ErrorHandler:
MsgBox Err.Number & Chr(13) & Err.Description
Resume ExitHandler
-------------------------------------------------------------------
it gives me error: 3061 Too Few Parameters Expected 1
pls advised.

 
Hello sahh1419, I have serious concerns about your Naming conventions,
Date
Month
Year
All of these words, are reserved words.. I would first address these issues.. A list of 'Bad FiledNames' is available.. Please look into that..
i want to unpaid records insert into another table when the paid field is equal to: zero(0)
If the 9 record of fee table is unpaid.the following code i have written in form_open event only insert only first record 9 times. but i need to insert the all 9 records insert in that table.
Why have you used a Form's event? Could this not simply be achieved in a Query, which again is NOT necessary as you are duplicating information again and again.. Copying data from one table to another !!

You might want to think over that again.. If you could exactly say what you want, we might be able to help you precisely..

On a side note, please enclose your code in CODE tags to make it more readable and presentable.. that might help identify any errors quickly..
Code:
    On Error GoTo ErrorHandler
    
    DoCmd.SetWarnings False
    Dim StrSQl As String, a As Date, D As Integer
    Dim db As DAO.Database
    a = Date
    D = Day(a)
    Set db = CurrentDb
    'Set rs = DB.OpenRecordset("feesms")
    
    StrSQl = "Insert into MsgOut (iid,msg,send,msgto) " & _
            "SELECT [GR No], 'Respected Parents!Your Child Fees Has Been Due..Please Paid the dues as earliest...', 'Yes', Mobile " & _
            "FROM feesms " & _
            "WHERE [D] > 10 AND ([paid] = 0 Or [paid] IS NULL)"
    
    db.Execute StrSQl, dbFailOnError
ExitHandler:
    DoCmd.SetWarnings True
    Exit Sub
ErrorHandler:
    MsgBox Err.Number & Chr(13) & Err.Description
    Resume ExitHandler
-------------------------------------------------------------------
it gives me error: 3061 Too Few Parameters Expected 1
pls advised.
before executing use Debug.Print and see what you get.. I think your StrSql is constructed very badly.. Try creating a Query to obtain the [GR No] first and then insert it..
 
[feesms] is a query not a table.perhaps it will be the error.
how i can get data from query;
 

Users who are viewing this thread

Back
Top Bottom