UNCARabid
Oct 3rd, 2000, 11:02 AM
Basically I'm looking for any code that will allow a findfirst to actually find data in a recordset in access 97.
If someone could send me an example that works I'd really love that.
I'm trying to write some vbs code that will search through a couple hundred text files and import the ones that haven't already been imported. The files are numbered sequentially. It has become bigger and bigger as I've tried to get it to work. So everything below is just a big failed attempt. It should be amusing to anyone who knows what they are doing.
Private Sub Command0_Click()
Dim strFile As String
Dim strPath As String
Dim intFileNumber As Integer
Dim strFirstFile As String
Dim strFileNumber As String
Dim datFile As Date
Dim strLine As String
Dim strSearch As String
Dim dbs As Database
Dim rst As Recordset
Dim matchno As Integer
Dim matchyes As Integer
Dim intCtr
Set dbs = CurrentDb
strPath = "\\Chapman\0DATA\Database\CDC\TRH\460\OMNICELL\"
strFile = "thho"
strFirstFile = Dir(strPath & strFile & "*.*", vbNormal)
intFileNumber = Val(Mid(strFirstFile, 5, 3))
intCtr = intFileNumber
For intCtr = intFileNumber To 366
Select Case intFileNumber
Case 0 To 9
strFileNumber = "00" & CStr(intFileNumber)
Case 10 To 99
strFileNumber = "0" & CStr(intFileNumber)
Case 100 To 366
strFileNumber = CStr(intFileNumber)
End Select
Open strPath & strFile & strFileNumber & ".int" For Input As #1
Line Input #1, strLine
strLine = Mid(strLine, 89, 14)
Close #1
strSearch = "Select [Date] From OmniCell Where [Date] = " & "" & strLine & ""
' strLine = "OmniCell"
'MsgBox strSearch
Set rst = dbs.OpenRecordset("OmniCell")
rst = rst.Seek("Date = " & "" & strLine & "", "Date")
' strLine = "[OmniCell].[Data] = " & strLine
' rst.FindFirst (strLine)
If rst.NoMatch = True Then
matchno = matchno + 1
DoCmd.TransferText acImportFixed, "Omni Style", "OmniCell", strPath & strFile & intFileNumber & ".int", False, ""
Else
matchyes = matchyes + 1
End If
intFileNumber = intFileNumber + 1
Next intCtr
dbs.Close
' MsgBox matchno & " " & matchyes
Exit_Command0_Click:
Exit Sub
End Sub
'Remember no matter how bad code gets there is always beer
If someone could send me an example that works I'd really love that.
I'm trying to write some vbs code that will search through a couple hundred text files and import the ones that haven't already been imported. The files are numbered sequentially. It has become bigger and bigger as I've tried to get it to work. So everything below is just a big failed attempt. It should be amusing to anyone who knows what they are doing.
Private Sub Command0_Click()
Dim strFile As String
Dim strPath As String
Dim intFileNumber As Integer
Dim strFirstFile As String
Dim strFileNumber As String
Dim datFile As Date
Dim strLine As String
Dim strSearch As String
Dim dbs As Database
Dim rst As Recordset
Dim matchno As Integer
Dim matchyes As Integer
Dim intCtr
Set dbs = CurrentDb
strPath = "\\Chapman\0DATA\Database\CDC\TRH\460\OMNICELL\"
strFile = "thho"
strFirstFile = Dir(strPath & strFile & "*.*", vbNormal)
intFileNumber = Val(Mid(strFirstFile, 5, 3))
intCtr = intFileNumber
For intCtr = intFileNumber To 366
Select Case intFileNumber
Case 0 To 9
strFileNumber = "00" & CStr(intFileNumber)
Case 10 To 99
strFileNumber = "0" & CStr(intFileNumber)
Case 100 To 366
strFileNumber = CStr(intFileNumber)
End Select
Open strPath & strFile & strFileNumber & ".int" For Input As #1
Line Input #1, strLine
strLine = Mid(strLine, 89, 14)
Close #1
strSearch = "Select [Date] From OmniCell Where [Date] = " & "" & strLine & ""
' strLine = "OmniCell"
'MsgBox strSearch
Set rst = dbs.OpenRecordset("OmniCell")
rst = rst.Seek("Date = " & "" & strLine & "", "Date")
' strLine = "[OmniCell].[Data] = " & strLine
' rst.FindFirst (strLine)
If rst.NoMatch = True Then
matchno = matchno + 1
DoCmd.TransferText acImportFixed, "Omni Style", "OmniCell", strPath & strFile & intFileNumber & ".int", False, ""
Else
matchyes = matchyes + 1
End If
intFileNumber = intFileNumber + 1
Next intCtr
dbs.Close
' MsgBox matchno & " " & matchyes
Exit_Command0_Click:
Exit Sub
End Sub
'Remember no matter how bad code gets there is always beer