I am writing code for a payment file in vba. The data for first name, last name, ssn, employee paid premium and cancel date should be in seperate cells. This should create five cells of data in the .xls file. All of the data is currently being lumped into the first cell. If anyone knows what I need to do here, I would be greatly appreciative. Thanks in advance! Here is the code:
With rstRecs
.CursorLocation = adUseClient
.CursorType = adOpenForwardOnly
.LockType = adLockReadOnly
.ActiveConnection = g_conOLEDB
.Open strSQL
Set .ActiveConnection = Nothing
lngEmployerNo = 0
If (Not (.EOF)) Then
strFileName = CreateNightBatchDirectory() & "Payments\UNUMProvident" & lngCarrier & "Client" & .Fields("EMPLOYER NUMBER").Value & ".txt"
Open strFileName For Output As #1
Add_Email_Process_Record True, 1, lngCarrier, strFileName, False, CInt(Asc("P") & Asc("F"))
Add_Daily_Process_Record "UNUMProvident" & lngCarrier, strFileName
Do While (Not (.EOF))
lngEmployerNo = .Fields("EMPLOYER NUMBER").Value
If (Not (BlankField(.Fields("FIRST NAME").Value))) Then
Print #1, Format(.Fields("FIRST NAME").Value, "!@@@@@@@@@@@@@@@");
Else
Print #1, Space$(15);
End If
If (Not (BlankField(.Fields("LAST NAME").Value))) Then
Print #1, Format(.Fields("LAST NAME").Value, "!@@@@@@@@@@@@@@@");
Else
Print #1, Space$(15);
End If
Print #1, Format(.Fields("EMPLOYEE SSN").Value, "000000000");
If (Not (BlankField(.Fields("EMPLOYEE PAID PREMIUM").Value))) Then
Print #1, Format(.Fields("EMPLOYEE PAID PREMIUM").Value, "0000000.00");
Else
Print #1, Space$(10);
End If
If (Not (BlankField(.Fields("CANCEL DATE").Value))) Then
Print #1, Format(.Fields("CANCEL DATE").Value, "MMDDYYYY");
Print #1, Space$(4);
Else
Print #1, Space$(12),
End If
Print #1,
.MoveNext
Loop
Close #1
End If
End With
With rstRecs
.CursorLocation = adUseClient
.CursorType = adOpenForwardOnly
.LockType = adLockReadOnly
.ActiveConnection = g_conOLEDB
.Open strSQL
Set .ActiveConnection = Nothing
lngEmployerNo = 0
If (Not (.EOF)) Then
strFileName = CreateNightBatchDirectory() & "Payments\UNUMProvident" & lngCarrier & "Client" & .Fields("EMPLOYER NUMBER").Value & ".txt"
Open strFileName For Output As #1
Add_Email_Process_Record True, 1, lngCarrier, strFileName, False, CInt(Asc("P") & Asc("F"))
Add_Daily_Process_Record "UNUMProvident" & lngCarrier, strFileName
Do While (Not (.EOF))
lngEmployerNo = .Fields("EMPLOYER NUMBER").Value
If (Not (BlankField(.Fields("FIRST NAME").Value))) Then
Print #1, Format(.Fields("FIRST NAME").Value, "!@@@@@@@@@@@@@@@");
Else
Print #1, Space$(15);
End If
If (Not (BlankField(.Fields("LAST NAME").Value))) Then
Print #1, Format(.Fields("LAST NAME").Value, "!@@@@@@@@@@@@@@@");
Else
Print #1, Space$(15);
End If
Print #1, Format(.Fields("EMPLOYEE SSN").Value, "000000000");
If (Not (BlankField(.Fields("EMPLOYEE PAID PREMIUM").Value))) Then
Print #1, Format(.Fields("EMPLOYEE PAID PREMIUM").Value, "0000000.00");
Else
Print #1, Space$(10);
End If
If (Not (BlankField(.Fields("CANCEL DATE").Value))) Then
Print #1, Format(.Fields("CANCEL DATE").Value, "MMDDYYYY");
Print #1, Space$(4);
Else
Print #1, Space$(12),
End If
Print #1,
.MoveNext
Loop
Close #1
End If
End With