A family of Microsoft relational database management systems designed for ease of use.
It's just a text file. The location (in no normalized order) at the top, and a list of serial numbers going down. I was having problems with how to get it to recognize that a new row was a different serial number, and then thought about just finding what character Access uses for a return/new line.
This is the code I came up with. It seems to be working so far. This is meant to be a temporary solution until I get all the files processed with items into the database, and logged into their correct location. I have forms set up that are meant for the actual users to add/edit things.
Dim sSerial As String, sDate As String, sSN As String
Dim dExpr As Date, dDate As Date
Dim iType As Integer, iContainer As Integer, iItem As Integer, iTransaction As Integer, i As Integer, iCount As Integer, iLength As Integer, iCheck As Integer
Set dbs = CurrentDb
dDate = Now
iContainer = Me.cboContainerID.Value
sSerial = Me.txtSerial.Value
sSerial = Replace(sSerial, Chr(13) & Chr(10), "")
iLength = Len(sSerial)
iCheck = iLength Mod 8
If iCheck <> 0 Then Exit Sub
iCount = (iLength \ 8) - 1
iTransaction = 2
iType = Me.grpItemTypeID.Value
For i = 0 To iCount
If i = 0 Then
sSN = Left(sSerial, 8)
Else
sSN = Mid(sSerial, (i * 8) + 1, 8)
End If
Debug.Print "i is " & i
Debug.Print "sSN is " & sSN
sDate = Mid(sSN, 3, 2) & "-01-" & Left(sSN, 2)
dExpr = CDate(sDate)
iItem = Nz(DLookup("ItemID", "tblItems", "SerialNumber = '" & sSN & "'"), 0)
If iItem = 0 Then
sSQL = "INSERT INTO tblItems (ItemTypeID, SerialNumber, ExpirationDate) VALUES (" & iType & ", '" & sSN & "' ," & Format(dExpr, "\#mm-dd-yyyy hh:mm:ss\#") & ");"
dbs.Execute sSQL, dbFailOnError
End If
iItem = Nz(DLookup("ItemID", "tblItems", "SerialNumber = '" & sSN & "'"), 0)
If iItem <> 0 Then
sSQL = "INSERT INTO tblTransactions (ItemID, TransactionTypeID, ContainerID, TransactionDate) VALUES (" & iItem & ", " & iTransaction & ", " & iContainer & ", " & Format(dDate, "\#mm-dd-yyyy hh:mm:ss\#") & ");"
dbs.Execute sSQL