I am using an Access 2000 database and trying to create reports for a payroll application. I have created queries in Access to draw the report information from. I am using VB DataEnvironment and Datareport. I have on report working, but have a problem with the second that I can not figure out.
Working Report. I created a Access query that pulls needed info from one table(All string types), I then get the VAL, * .01 to set the decimal correctly, then order it the way the user selects. The Query is HoursQuery, and in the DataEnvironment command I use SELECT * FROM HoursQuery. Here is the code I use when calling the report
SQL$ = ""
SQL$ = "SELECT Val(PAYEMP) as PAYEMP, Name,"
SQL$ = SQL$ & "VAL(RegHrs) * .01 AS RegHrs,"
SQL$ = SQL$ & "VAL(OvtHrs) * .01 AS OvtHrs,"
SQL$ = SQL$ & "VAL(dblHrs) * .01 AS DblHrs,"
SQL$ = SQL$ & "VAL(reg2Hrs) * .01 AS Reg2Hrs,"
SQL$ = SQL$ & "VAL(Reg3Hrs) * .01 AS Reg3Hrs,"
SQL$ = SQL$ & "VAL(Ovt2Hrs) * .01 AS Ovt2Hrs,"
SQL$ = SQL$ & "VAL(Ovt3Hrs) * .01 AS Ovt3Hrs,"
SQL$ = SQL$ & "VAL(Oth1Ern) * .01 as Oth1Ern,"
SQL$ = SQL$ & "VAL(SickHrs) * .01 AS SickHrs,"
SQL$ = SQL$ & "VAL(VacHrs) * .01 AS VacHrs,"
SQL$ = SQL$ & "VAL(HolHrs) * .01 AS HolHrs,"
SQL$ = SQL$ & "VAL(CommErn) * .01 AS CommErn,"
SQL$ = SQL$ & "VAL(Meals) * .01 AS Meals,"
SQL$ = SQL$ & "VAL(Tips) * .01 AS Tips,"
SQL$ = SQL$ & "VAL(MiscHrs) * .01 AS MiscHrs,"
SQL$ = SQL$ & "VAL(Oth2Ern) * .01 AS Oth2Ern,"
SQL$ = SQL$ & "VAL(AdjToNet) * .01 AS AdjToNet,"
SQL$ = SQL$ & "RecType,DeleteRec"
If PR.PAGEORDER = 5 And ManPage% = 0 Then
frmBalanceMenu.KeyPreview = False
Disable
fraPaging.Visible = True
txtPaging.Text = ""
txtPaging.SetFocus
Stop
Exit Sub
End If
If PR.PAGEORDER = 1 Or ManPage% = 1 Then
SQL$ = SQL$ & " FROM HoursQuery WHERE _
RecType='05' AND DeleteRec <>'D' ORDER BY Name ASC"
GoTo Choose
End If
If PR.PAGEORDER = 2 Or ManPage% = 2 Then
SQL$ = SQL$ & " FROM HoursQuery WHERE _
RecType='05' AND DeleteRec <>'D' ORDER BY PAYEMP ASC"
GoTo Choose
End If
If PR.PAGEORDER = 3 Or ManPage% = 3 Then
SQL$ = SQL$ & " FROM HoursQuery WHERE _
RecType='05' AND DeleteRec <>'D' ORDER BY Div,Dept,PAYEMP ASC"
GoTo Choose
End If
If PR.PAGEORDER = 4 Or ManPage% = 4 Then
SQL$ = SQL$ & " FROM HoursQuery WHERE _
RecType='05' AND DeleteRec <>'D' ORDER BY Div,Dept,Name ASC"
GoTo Choose
End If
Exit Sub
Choose:
DtaReports.rscomHourlyRpt.Open SQL$
RptHourly.PrintReport
MsgBox "printing"
This works exactly like I need. Now for the problem report. It is a little more complicated.
I have created a query in Access with 3 joined tables.
In the DataEnvironment I use SELECT * FROM Salary2Query.
The report runs fine with all the information needed included,
but I need to get the VAL of the string data and divide by .01 just as before.
But in this case I keep getting the error "No Value given for one or more require
parameters". I'm not sure what I am doing wrong.
COuld it be the joining of the tables giving
me problems? I'm rather new to VB, so detailed help would be valued. Here is the code for it
'Checking% = 1
Checking% = 2
SQL$ = ""
SQL$ = "SELECT Rates.PAYEMP,EmployeeHours.PAYEMP,LName,FstName,"
SQL$ = SQL$ & "VAL(RegHrs) * .01 AS RegHrs,"
SQL$ = SQL$ & "VAL(OvtHrs) * .01 AS OvtHrs,"
SQL$ = SQL$ & "VAL(dblHrs) * .01 AS DblHrs,"
SQL$ = SQL$ & "VAL(Oth1Ern) * .01 as Oth1Ern,"
SQL$ = SQL$ & "VAL(SickHrs) * .01 AS SickHrs,"
SQL$ = SQL$ & "VAL(VacHrs) * .01 AS VacHrs,"
SQL$ = SQL$ & "VAL(HolHrs) * .01 AS HolHrs,"
SQL$ = SQL$ & "VAL(CommErn) * .01 AS CommErn,"
SQL$ = SQL$ & "VAL(Meals) * .01 AS Meals,"
SQL$ = SQL$ & "VAL(Tips) * .01 AS Tips,"
SQL$ = SQL$ & "VAL(MiscHrs) * .01 AS MiscHrs,"
SQL$ = SQL$ & "VAL(Oth2Ern) * .01 AS Oth2Ern,"
SQL$ = SQL$ & "VAL(AdjToNet) * .01 AS AdjToNet,DeletRec "
SQL$ = SQL$ & "FROM Salary2Query WHERE DeleteRec <>'D'"
If Checking% = 2 Then SQL$ = SQL$ & " ORDER BY Rates.PAYEMP asc"
If Checking% = 1 Then SQL$ = SQL$ & " ORDER BY LName,FstName asc"
DtaReports.rscomSalary.Open SQL$
RptSalary.PrintReport
MsgBox "printing"
Any ideas or help would be greatly appreciated! Thanks
Catrina
Working Report. I created a Access query that pulls needed info from one table(All string types), I then get the VAL, * .01 to set the decimal correctly, then order it the way the user selects. The Query is HoursQuery, and in the DataEnvironment command I use SELECT * FROM HoursQuery. Here is the code I use when calling the report
SQL$ = ""
SQL$ = "SELECT Val(PAYEMP) as PAYEMP, Name,"
SQL$ = SQL$ & "VAL(RegHrs) * .01 AS RegHrs,"
SQL$ = SQL$ & "VAL(OvtHrs) * .01 AS OvtHrs,"
SQL$ = SQL$ & "VAL(dblHrs) * .01 AS DblHrs,"
SQL$ = SQL$ & "VAL(reg2Hrs) * .01 AS Reg2Hrs,"
SQL$ = SQL$ & "VAL(Reg3Hrs) * .01 AS Reg3Hrs,"
SQL$ = SQL$ & "VAL(Ovt2Hrs) * .01 AS Ovt2Hrs,"
SQL$ = SQL$ & "VAL(Ovt3Hrs) * .01 AS Ovt3Hrs,"
SQL$ = SQL$ & "VAL(Oth1Ern) * .01 as Oth1Ern,"
SQL$ = SQL$ & "VAL(SickHrs) * .01 AS SickHrs,"
SQL$ = SQL$ & "VAL(VacHrs) * .01 AS VacHrs,"
SQL$ = SQL$ & "VAL(HolHrs) * .01 AS HolHrs,"
SQL$ = SQL$ & "VAL(CommErn) * .01 AS CommErn,"
SQL$ = SQL$ & "VAL(Meals) * .01 AS Meals,"
SQL$ = SQL$ & "VAL(Tips) * .01 AS Tips,"
SQL$ = SQL$ & "VAL(MiscHrs) * .01 AS MiscHrs,"
SQL$ = SQL$ & "VAL(Oth2Ern) * .01 AS Oth2Ern,"
SQL$ = SQL$ & "VAL(AdjToNet) * .01 AS AdjToNet,"
SQL$ = SQL$ & "RecType,DeleteRec"
If PR.PAGEORDER = 5 And ManPage% = 0 Then
frmBalanceMenu.KeyPreview = False
Disable
fraPaging.Visible = True
txtPaging.Text = ""
txtPaging.SetFocus
Stop
Exit Sub
End If
If PR.PAGEORDER = 1 Or ManPage% = 1 Then
SQL$ = SQL$ & " FROM HoursQuery WHERE _
RecType='05' AND DeleteRec <>'D' ORDER BY Name ASC"
GoTo Choose
End If
If PR.PAGEORDER = 2 Or ManPage% = 2 Then
SQL$ = SQL$ & " FROM HoursQuery WHERE _
RecType='05' AND DeleteRec <>'D' ORDER BY PAYEMP ASC"
GoTo Choose
End If
If PR.PAGEORDER = 3 Or ManPage% = 3 Then
SQL$ = SQL$ & " FROM HoursQuery WHERE _
RecType='05' AND DeleteRec <>'D' ORDER BY Div,Dept,PAYEMP ASC"
GoTo Choose
End If
If PR.PAGEORDER = 4 Or ManPage% = 4 Then
SQL$ = SQL$ & " FROM HoursQuery WHERE _
RecType='05' AND DeleteRec <>'D' ORDER BY Div,Dept,Name ASC"
GoTo Choose
End If
Exit Sub
Choose:
DtaReports.rscomHourlyRpt.Open SQL$
RptHourly.PrintReport
MsgBox "printing"
This works exactly like I need. Now for the problem report. It is a little more complicated.
I have created a query in Access with 3 joined tables.
In the DataEnvironment I use SELECT * FROM Salary2Query.
The report runs fine with all the information needed included,
but I need to get the VAL of the string data and divide by .01 just as before.
But in this case I keep getting the error "No Value given for one or more require
parameters". I'm not sure what I am doing wrong.
COuld it be the joining of the tables giving
me problems? I'm rather new to VB, so detailed help would be valued. Here is the code for it
'Checking% = 1
Checking% = 2
SQL$ = ""
SQL$ = "SELECT Rates.PAYEMP,EmployeeHours.PAYEMP,LName,FstName,"
SQL$ = SQL$ & "VAL(RegHrs) * .01 AS RegHrs,"
SQL$ = SQL$ & "VAL(OvtHrs) * .01 AS OvtHrs,"
SQL$ = SQL$ & "VAL(dblHrs) * .01 AS DblHrs,"
SQL$ = SQL$ & "VAL(Oth1Ern) * .01 as Oth1Ern,"
SQL$ = SQL$ & "VAL(SickHrs) * .01 AS SickHrs,"
SQL$ = SQL$ & "VAL(VacHrs) * .01 AS VacHrs,"
SQL$ = SQL$ & "VAL(HolHrs) * .01 AS HolHrs,"
SQL$ = SQL$ & "VAL(CommErn) * .01 AS CommErn,"
SQL$ = SQL$ & "VAL(Meals) * .01 AS Meals,"
SQL$ = SQL$ & "VAL(Tips) * .01 AS Tips,"
SQL$ = SQL$ & "VAL(MiscHrs) * .01 AS MiscHrs,"
SQL$ = SQL$ & "VAL(Oth2Ern) * .01 AS Oth2Ern,"
SQL$ = SQL$ & "VAL(AdjToNet) * .01 AS AdjToNet,DeletRec "
SQL$ = SQL$ & "FROM Salary2Query WHERE DeleteRec <>'D'"
If Checking% = 2 Then SQL$ = SQL$ & " ORDER BY Rates.PAYEMP asc"
If Checking% = 1 Then SQL$ = SQL$ & " ORDER BY LName,FstName asc"
DtaReports.rscomSalary.Open SQL$
RptSalary.PrintReport
MsgBox "printing"
Any ideas or help would be greatly appreciated! Thanks
Catrina