FacilitiesCAD
Technical User
I am looking for an easyer way to do a task.
I want to maintain a database of aproximately 2000 drawings.
currently I run a .bat routine to generate a text file that has all the .dwg files on a paticular drive.
the routine is simple.
make_dwg_lst.bat
dir *.dwg /s >dwg_lst.txt
This generates a file like this:
Volume in drive * is ****
Volume Serial Number is ****-****
Directory of Drive:\path1
02/27/04 11:29a 39,501 File1.dwg
02/09/04 10:57a 295,727 File2.DWG
02/09/04 10:57a 461,956 File3.dwg
3 File(s) 797,184 bytes
Directory of Drive:\path2
08/06/02 08:01a 94,238 File4.dwg
etc
Since the data is spread out I used VB code in excel to organise the data before bringing it into access. At the bottom of this post is the code I used to organize the data as I am trying to put it into access.
First thing I want to do is make the code work. It doesn't because I don't know how to make/goto a new record. It was easy in excel because I'm more familiar with that.
Second I would like to compare the newly added data to data I already have because I have other fields that I input in like Project_Name1 etc that don't come from this automation. I would like to get rid of new duplicates.
(this doesn't need to be in the vb code it can be in a seperate querry)
Third I would like to get the routine to run my .bat code for me as well. I figure I could delete the existing .txt file, then run .bat then wait and then run the rest of the routine but I'm unsure how to implement that.
As you can see my BIG concer is how to create a new record in my VB code. All VB code I've done before this was just in one record.
Tim
Private Sub do_all_Click()
Dim L() As String
Dim Xa As String
Dim i As Integer
Dim m As Integer
Dim n As Integer
i = 0
Dim FileList As String
FileList = "Drive:\Path\File.txt"
Open FileList For Input As #1
Do While Not EOF(1)
i = i + 1
ReDim Preserve L(i) As String
Line Input #1, L(i)
Loop
Close #1
'-----------------------------------------
'Enter contents of Array into Column A (ideally a new table)
' Loop the number of lines found in FileList
m = 1
' start on 4th line
For n = 4 To i
' another loop to put L(#) into each cell 'record
' m = row number 'now record number
If Left(L, 14) = " Directory of " Then
Xa = Mid(L, 15) & "\"
L = ""
End If
If Mid(L, 18, 4) = "File" Then
L = ""
End If
If Mid(L, 1, 4) = " " Then
L = ""
End If
'ThisWorkbook.Sheets("Sheet1").Cells(n, 1) = L
' Cells(m, 1) = Xa
'Me.Text1 = Xa
'Me.Path1 = Xa 'moved to after if statement
' Cells(m, 2) = Mid(L, 1, 9)
Me.Saved_Date1 = Mid(L, 1, 9)
' Cells(m, 3) = Mid(L, 9, 8)
Me.Saved_Time1 = Mid(L, 9, 8)
' Cells(m, 4) = Mid(L, 17, 22)
Me.File_Size1 = Mid(L, 17, 22)
' Cells(m, 5) = Mid(L, 40)
Me.File1 = Mid(L, 40)
If L <> "" Then
' m = m + 1
Me.Path1 = Xa
'''Need Help Here
'''DoCmd.GoToRecord
'''DoCmd.GoToRecord , , acNext
End If
Next n
End Sub
I want to maintain a database of aproximately 2000 drawings.
currently I run a .bat routine to generate a text file that has all the .dwg files on a paticular drive.
the routine is simple.
make_dwg_lst.bat
dir *.dwg /s >dwg_lst.txt
This generates a file like this:
Volume in drive * is ****
Volume Serial Number is ****-****
Directory of Drive:\path1
02/27/04 11:29a 39,501 File1.dwg
02/09/04 10:57a 295,727 File2.DWG
02/09/04 10:57a 461,956 File3.dwg
3 File(s) 797,184 bytes
Directory of Drive:\path2
08/06/02 08:01a 94,238 File4.dwg
etc
Since the data is spread out I used VB code in excel to organise the data before bringing it into access. At the bottom of this post is the code I used to organize the data as I am trying to put it into access.
First thing I want to do is make the code work. It doesn't because I don't know how to make/goto a new record. It was easy in excel because I'm more familiar with that.
Second I would like to compare the newly added data to data I already have because I have other fields that I input in like Project_Name1 etc that don't come from this automation. I would like to get rid of new duplicates.
(this doesn't need to be in the vb code it can be in a seperate querry)
Third I would like to get the routine to run my .bat code for me as well. I figure I could delete the existing .txt file, then run .bat then wait and then run the rest of the routine but I'm unsure how to implement that.
As you can see my BIG concer is how to create a new record in my VB code. All VB code I've done before this was just in one record.
Tim
Private Sub do_all_Click()
Dim L() As String
Dim Xa As String
Dim i As Integer
Dim m As Integer
Dim n As Integer
i = 0
Dim FileList As String
FileList = "Drive:\Path\File.txt"
Open FileList For Input As #1
Do While Not EOF(1)
i = i + 1
ReDim Preserve L(i) As String
Line Input #1, L(i)
Loop
Close #1
'-----------------------------------------
'Enter contents of Array into Column A (ideally a new table)
' Loop the number of lines found in FileList
m = 1
' start on 4th line
For n = 4 To i
' another loop to put L(#) into each cell 'record
' m = row number 'now record number
If Left(L, 14) = " Directory of " Then
Xa = Mid(L, 15) & "\"
L = ""
End If
If Mid(L, 18, 4) = "File" Then
L = ""
End If
If Mid(L, 1, 4) = " " Then
L = ""
End If
'ThisWorkbook.Sheets("Sheet1").Cells(n, 1) = L
' Cells(m, 1) = Xa
'Me.Text1 = Xa
'Me.Path1 = Xa 'moved to after if statement
' Cells(m, 2) = Mid(L, 1, 9)
Me.Saved_Date1 = Mid(L, 1, 9)
' Cells(m, 3) = Mid(L, 9, 8)
Me.Saved_Time1 = Mid(L, 9, 8)
' Cells(m, 4) = Mid(L, 17, 22)
Me.File_Size1 = Mid(L, 17, 22)
' Cells(m, 5) = Mid(L, 40)
Me.File1 = Mid(L, 40)
If L <> "" Then
' m = m + 1
Me.Path1 = Xa
'''Need Help Here
'''DoCmd.GoToRecord
'''DoCmd.GoToRecord , , acNext
End If
Next n
End Sub