If...Then...Else Question

K

kerry

I have the following code that prints seasonal and nonseasonal wage records
for each employee. I can't seem to figure out how to add the code necessary
if an employee has seasonal AND nonseasonal wages for it to print out two
records for that one employee. Is there anyone out there that can help me
with this?

If rsDetailInfo!SeasonalWages > 0 Then
'print employee record
'print season wages
Print #1, "S" _
& rsDetailInfo!SocSecNum _
& Pad(rsDetailInfo!LastName, 20) _
& Pad(Left(rsDetailInfo!FirstName, 12), 12) _
& IIf(IsNull(rsDetailInfo!MiddleInitial), " ", rsDetailInfo!MiddleInitial) _
& "23" _
& Format(bteQuarter, "00") & strYear _
& Space(12) _
& CStr(Format(RemoveDecimals(rsDetailInfo!SeasonalWages), "00000000000000")) _
& "00000000000000" & "00000000000000" _
& Space(37) _
& "UTAX" _
& rsDetailInfo!StateID _
& Space(20) _
& "00000000000000" & "00000000000000" _
& "S" _
& Space(5) _
& "0" _
& IIf(rsDetailInfo!WorkedMonth1 = "Y", "1", "0") _
& IIf(rsDetailInfo!WorkedMonth2 = "Y", "1", "0") _
& IIf(rsDetailInfo!WorkedMonth3 = "Y", "1", "0") _
& strCurrentEmployer & rsDetailInfo!ITWSuffix _
& IIf(rsDetailInfo!Gender = "F", 1, 0) _
& "00000000" & "00000000" _
& Space(33)

lngEmpCount = lngEmpCount + 1
lngSTotal = lngSTotal + 1

ElseIf rsDetailInfo!NonseasonalWages > 0 Then

'Nonseasonal wages
Print #1, "S" _
& rsDetailInfo!SocSecNum _
& Pad(rsDetailInfo!LastName, 20) _
& Pad(Left(rsDetailInfo!FirstName, 12), 12) _
& IIf(IsNull(rsDetailInfo!MiddleInitial), " ", rsDetailInfo!MiddleInitial) _
& "23" _
& Format(bteQuarter, "00") & strYear _
& Space(12) _
& CStr(Format(RemoveDecimals(rsDetailInfo!NonseasonalWages),
"00000000000000")) _
& "00000000000000" & "00000000000000" _
& Space(37) _
& "UTAX" _
& rsDetailInfo!StateID _
& Space(20) _
& "00000000000000" & "00000000000000" _
& "N" _
& Space(5) _
& "0" _
& IIf(rsDetailInfo!WorkedMonth1 = "Y", "1", "0") _
& IIf(rsDetailInfo!WorkedMonth2 = "Y", "1", "0") _
& IIf(rsDetailInfo!WorkedMonth3 = "Y", "1", "0") _
& strCurrentEmployer & rsDetailInfo!ITWSuffix _
& IIf(rsDetailInfo!Gender = "F", 1, 0) _
& "00000000" & "00000000" _
& Space(33)

lngEmpCount = lngEmpCount + 1
lngSTotal = lngSTotal + 1



Else
'print employee record
' I tried adding the statement below but it still doesn't work!!!!!!!
If rsDetailInfo!SeasonalWages > 0 And rsDetailInfo!NonseasonalWages > 0 Then

Print #1, "S" _
& rsDetailInfo!SocSecNum _
& IIf(IsNull(rsDetailInfo!LastName), Pad(" ", 20),
Pad(rsDetailInfo!LastName, 20)) _
& IIf(IsNull(rsDetailInfo!FirstName), Pad(" ", 12),
Pad(Left(rsDetailInfo!FirstName, 12), 12)) _
& IIf(IsNull(rsDetailInfo!MiddleInitial), " ", rsDetailInfo!MiddleInitial) _
& "23" _
& Format(bteQuarter, "00") & strYear _
& Space(12) _
& CStr(Format(RemoveDecimals(IIf(rsDetailInfo!SeasonalWages > 0,
rsDetailInfo!SeasonalWages, rsDetailInfo!NonseasonalWages)),
"00000000000000")) _
& "00000000000000" & "00000000000000" _
& Space(37) _
& "UTAX" _
& rsDetailInfo!StateID _
& Space(20) _
& "00000000000000" & "00000000000000" _
& "S" _
& Space(5) _
& "0" _
& IIf(rsDetailInfo!WorkedMonth1 = "Y", "1", "0") _
& IIf(rsDetailInfo!WorkedMonth2 = "Y", "1", "0") _
& IIf(rsDetailInfo!WorkedMonth3 = "Y", "1", "0") _
& strCurrentEmployer & rsDetailInfo!ITWSuffix _
& IIf(rsDetailInfo!Gender = "F", 1, 0) _
& "00000000" & "00000000" _
& Space(33)

lngEmpCount = lngEmpCount + 1
lngSTotal = lngSTotal + 1
 
T

TonyT

Try the following;
If rsDetailInfo!SeasonalWages > 0 Then
'print employee record
'print season wages
Print #1, "S" _
& rsDetailInfo!SocSecNum _
& Pad(rsDetailInfo!LastName, 20) _
& Pad(Left(rsDetailInfo!FirstName, 12), 12) _
& IIf(IsNull(rsDetailInfo!MiddleInitial), " ", rsDetailInfo!MiddleInitial) _
& "23" _
& Format(bteQuarter, "00") & strYear _
& Space(12) _
& CStr(Format(RemoveDecimals(rsDetailInfo!SeasonalWages), "00000000000000")) _
& "00000000000000" & "00000000000000" _
& Space(37) _
& "UTAX" _
& rsDetailInfo!StateID _
& Space(20) _
& "00000000000000" & "00000000000000" _
& "S" _
& Space(5) _
& "0" _
& IIf(rsDetailInfo!WorkedMonth1 = "Y", "1", "0") _
& IIf(rsDetailInfo!WorkedMonth2 = "Y", "1", "0") _
& IIf(rsDetailInfo!WorkedMonth3 = "Y", "1", "0") _
& strCurrentEmployer & rsDetailInfo!ITWSuffix _
& IIf(rsDetailInfo!Gender = "F", 1, 0) _
& "00000000" & "00000000" _
& Space(33) End If
If rsDetailInfo!NonseasonalWages > 0 Then
'Nonseasonal wages
Print #1, "S" _
& rsDetailInfo!SocSecNum _
& Pad(rsDetailInfo!LastName, 20) _
& Pad(Left(rsDetailInfo!FirstName, 12), 12) _
& IIf(IsNull(rsDetailInfo!MiddleInitial), " ", rsDetailInfo!MiddleInitial) _
& "23" _
& Format(bteQuarter, "00") & strYear _
& Space(12) _
& CStr(Format(RemoveDecimals(rsDetailInfo!NonseasonalWages),
"00000000000000")) _
& "00000000000000" & "00000000000000" _
& Space(37) _
& "UTAX" _
& rsDetailInfo!StateID _
& Space(20) _
& "00000000000000" & "00000000000000" _
& "N" _
& Space(5) _
& "0" _
& IIf(rsDetailInfo!WorkedMonth1 = "Y", "1", "0") _
& IIf(rsDetailInfo!WorkedMonth2 = "Y", "1", "0") _
& IIf(rsDetailInfo!WorkedMonth3 = "Y", "1", "0") _
& strCurrentEmployer & rsDetailInfo!ITWSuffix _
& IIf(rsDetailInfo!Gender = "F", 1, 0) _
& "00000000" & "00000000" _
& Space(33)
End If
lngEmpCount = lngEmpCount + 1
lngSTotal = lngSTotal + 1


This way the employee can be found in both seasanal and non-seasonal, I
removed one of your lngEmpCount = lngEmpCount + 1 and lngSTotal counts, as I
initially thought they were record counters and would have moved onto the
next record before they ought to, so you probably want to re-add that after
the Seasonal section at the top.

hope that works,

TonyT..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top