D
domibud
Hi... I'm trying to make a database for employees transport/taxi expenses.
This is the first time I'm making a database and I'm new to VBA language.
I'm using Ms. Access 2003 and this database will be in a multi-user
environment.
The output is employee's expense report.
I made 1 report in Access, and I want the user to be able to enter certain
criteria/filter for his/her report.
For entering those criteria/filter I made a form with 3 text box:
1. for entering employee's name
2 & 3. for entering StartDate and EndDate
From that form, I made a button to open the report.
Here's the code for that button:
Private Sub CreateSalesReport_Click()
Dim StrSql As String
Dim YourName As String
Dim StartDate As String
Dim EndDate As String
StrSql = "SELECT [VoucherReleaseTest].[#2-#8],
VoucherReleaseTest].Requester, [VoucherDetailed].DateUse, " _
& "[VoucherDetailed].Fare, [VoucherDetailed].DepartAddr,
[VoucherDetailed].DestAddr, " _
& "[VoucherDetailed].DestCo, [VoucherDetailed].Remark " _
& "FROM [VoucherReleaseTest] INNER JOIN [VoucherDetailed] " _
& "ON [VoucherReleaseTest].[#2-#8] = [VoucherDetailed].[#2-#8] " _
& "WHERE ((([VoucherReleaseTest].Requester)= YourName) AND " _
& "(([VoucherDetailed].DateUse) Between #" & StartDate & "# And
#" & EndDate & "#));"
Application.Reports("SalesTaxiExpenseReport").RecordSource = StrSql
DoCmd.OpenReport ("SalesTaxiExpenseReport")
End Sub
When I run this, I've an error message (run-time error 2451):
The report name 'SalesTaxiExpenseReport' you entered is misspelled and
refers to a report that isn't open or doesn't exist.
When I debug, the error seems to be in this line:
Application.Reports("SalesTaxiExpenseReport").RecordSource = StrSql
I already double checked the report's name, and I've got it right.
When I change above code to:
Application.Reports(0).RecordSource = StrSql
I've got an error message (run-time error 2457):
The number you used to refer to the report is invalid
I only have 1 report in this database, and from access help, I know that the
report index start from 0.
Can anyone help me to the right direction?
This is the first time I'm making a database and I'm new to VBA language.
I'm using Ms. Access 2003 and this database will be in a multi-user
environment.
The output is employee's expense report.
I made 1 report in Access, and I want the user to be able to enter certain
criteria/filter for his/her report.
For entering those criteria/filter I made a form with 3 text box:
1. for entering employee's name
2 & 3. for entering StartDate and EndDate
From that form, I made a button to open the report.
Here's the code for that button:
Private Sub CreateSalesReport_Click()
Dim StrSql As String
Dim YourName As String
Dim StartDate As String
Dim EndDate As String
StrSql = "SELECT [VoucherReleaseTest].[#2-#8],
VoucherReleaseTest].Requester, [VoucherDetailed].DateUse, " _
& "[VoucherDetailed].Fare, [VoucherDetailed].DepartAddr,
[VoucherDetailed].DestAddr, " _
& "[VoucherDetailed].DestCo, [VoucherDetailed].Remark " _
& "FROM [VoucherReleaseTest] INNER JOIN [VoucherDetailed] " _
& "ON [VoucherReleaseTest].[#2-#8] = [VoucherDetailed].[#2-#8] " _
& "WHERE ((([VoucherReleaseTest].Requester)= YourName) AND " _
& "(([VoucherDetailed].DateUse) Between #" & StartDate & "# And
#" & EndDate & "#));"
Application.Reports("SalesTaxiExpenseReport").RecordSource = StrSql
DoCmd.OpenReport ("SalesTaxiExpenseReport")
End Sub
When I run this, I've an error message (run-time error 2451):
The report name 'SalesTaxiExpenseReport' you entered is misspelled and
refers to a report that isn't open or doesn't exist.
When I debug, the error seems to be in this line:
Application.Reports("SalesTaxiExpenseReport").RecordSource = StrSql
I already double checked the report's name, and I've got it right.
When I change above code to:
Application.Reports(0).RecordSource = StrSql
I've got an error message (run-time error 2457):
The number you used to refer to the report is invalid
I only have 1 report in this database, and from access help, I know that the
report index start from 0.
Can anyone help me to the right direction?