pbuethe
Returning User
- Local time
- Today, 16:59
- Joined
- Apr 9, 2002
- Messages
- 210
I am getting "invalid use of null" error on the following code:
The "invalid use of null" comes on the line:
SpecCode = rst!txtSpecCode
I am trying to copy 4 fields from the second of two records, where the two records have the same txtIDNbr, to the first record. The table, tblAdjMasterSort, is sorted by txtIDNbr and txtAdjTapeNbr; the records with the earlier txtAdjTapeNbr are blank in the 4 fields, txtSpecCode, txtBillType, txtCatOfServ, and txtRateCode.
What am I doing wrong? Any help is appreciated.
Code:
Public Sub DupTapeData()
Dim prevRecID As String
Dim thisRecID As String
Dim SpecCode As String
Dim CatOfServ As String
Dim BillType As String
Dim RateCode As String
Dim dbs As Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblAdjMasterSort", dbOpenTable)
With rst
.MoveFirst
.Edit
End With
thisRecID = rst![txtIDNbr]
Do Until rst.EOF
rst.MoveNext
prevRecID = thisRecID
thisRecID = rst![txtIDNbr]
SpecCode = rst!txtSpecCode
CatOfServ = rst!txtCatOfServ
BillType = rst!txtBillType
RateCode = rst!txtRateCode
If thisRecID = prevRecID Then
With rst
.MovePrevious
!txtSpecCode = SpecCode
!txtCatOfServ = CatOfServ
!txtBillType = BillType
!txtRateCode = RateCode
.Update
End With
End If
Loop
With rst
.Update
.Close
End With
End Sub
The "invalid use of null" comes on the line:
SpecCode = rst!txtSpecCode
I am trying to copy 4 fields from the second of two records, where the two records have the same txtIDNbr, to the first record. The table, tblAdjMasterSort, is sorted by txtIDNbr and txtAdjTapeNbr; the records with the earlier txtAdjTapeNbr are blank in the 4 fields, txtSpecCode, txtBillType, txtCatOfServ, and txtRateCode.
What am I doing wrong? Any help is appreciated.