Click here to Skip to main content
15,892,072 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: email application in vb without the use of MAPI controls Pin
Richard MacCutchan3-Mar-11 3:23
mveRichard MacCutchan3-Mar-11 3:23 
AnswerRe: email application in vb without the use of MAPI controls Pin
_Erik_3-Mar-11 2:30
_Erik_3-Mar-11 2:30 
AnswerRe: email application in vb without the use of MAPI controls Pin
Simon_Whale3-Mar-11 2:57
Simon_Whale3-Mar-11 2:57 
GeneralRe: email application in vb without the use of MAPI controls Pin
K Suresh Nair3-Mar-11 3:12
K Suresh Nair3-Mar-11 3:12 
QuestionVisual Basic: Do Until i = 1 To LastFolderFound - Adding a new record Number Pin
Memphis761-Mar-11 22:59
Memphis761-Mar-11 22:59 
AnswerRe: Visual Basic: Do Until i = 1 To LastFolderFound - Adding a new record Number [modified] Pin
_Erik_1-Mar-11 23:26
_Erik_1-Mar-11 23:26 
GeneralRe: Visual Basic: Do Until i = 1 To LastFolderFound - Adding a new record Number Pin
Memphis762-Mar-11 6:24
Memphis762-Mar-11 6:24 
GeneralRe: Visual Basic: Do Until i = 1 To LastFolderFound - Adding a new record Number Pin
Memphis762-Mar-11 14:02
Memphis762-Mar-11 14:02 
Hi Erik! Sorry to bother again
I did the changes you suggested and some other changes to make it work
Example:
I had to put "With rst" inside "For Each sFolder" otherwise it was giving me:
SearchForFolder(): Error 91 - Object variable or with block not set
CmdSearch(): Error 3219 - Operation is not allowed in this context.
I also removed the parameter from SearchForFolders(adoCON) to CmdSearch_Click(): it was also giving me Error 91

The only problem I still have is that if in a folder I have more folders each will have the same number. So it doesn't increment with the subfolders but the folders. Example:
FolderID   FolderName	FolderPath		
1	   19	        C:\Users\Name\Sample\19
1          20           C:\Users\Name\Sample\20
2          1            C:\Users\Name\Sample\20\1
2          2            C:\Users\Name\Sample\20\2
2          7            C:\Users\Name\Sample\20\7

etc
Any idea how to get around this?
New snippet
Option Compare Database
Option Explicit
Private Const BIF_RETURNONLYFSDIRS = 1
Private Const BIF_DONTGOBELOWDOMAIN = 2
Private Const BIF_EDITBOX = &H10
Private Const BIF_NEWDIALOGSTYLE = &H40
Private Const MAX_PATH = 260
Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Private Type BrowseInfo
    hWndOwner      As Long
    pIDLRoot       As Long
    pszDisplayName As Long
    lpszTitle      As Long
    ulFlags        As Long
    lpfnCallback   As Long
    lParam         As Long
    iImage         As Long
End Type
Dim BrowsePath As String

Private Sub CmdBrowse_Click()
On Error GoTo ErrorHandler
Dim lpIDList As Long, strTitle As String, tBrwInfo As BrowseInfo
26    strTitle = "Please select your media directory:"
27    With tBrwInfo
28        .hWndOwner = Me.hwnd
29        .lpszTitle = lstrcat(strTitle, "")
30        .ulFlags = BIF_RETURNONLYFSDIRS + BIF_DONTGOBELOWDOMAIN + BIF_EDITBOX + BIF_NEWDIALOGSTYLE
    End With
32    lpIDList = SHBrowseForFolder(tBrwInfo)
33    If (lpIDList) Then
34        BrowsePath = Space(MAX_PATH)
35        SHGetPathFromIDList lpIDList, BrowsePath
36        BrowsePath = Left(BrowsePath, InStr(BrowsePath, vbNullChar) - 1)
37        Me.txt_String = BrowsePath
    End If
ErrorExit:
    Exit Sub
ErrorHandler:
    MsgBox "Error in CmdBrowse() " & vbCrLf & _
           "Number: " & Err.Number & vbCrLf & _
           "Description: " & Err.Description & vbCrLf & _
           "Line Number: " & Erl()
    Err.Clear
    Resume ErrorExit
End Sub

Private Sub CmdSearch_Click()
On Error GoTo ErrorHandler
Dim adoCON As New ADODB.Connection, adoRST As New ADODB.Recordset
53    'DoCmd.SetWarnings False
54    'DoCmd.RunSQL "Delete * FROM FoldersPath"
55    'DoCmd.SetWarnings True
56    Set adoCON = CurrentProject.Connection
57    adoRST.Open "SELECT * FROM FoldersPath", adoCON, adOpenKeyset, adLockOptimistic
58    SearchForFolders adoRST, BrowsePath, 1
59    adoRST.Close
60    Set adoRST = Nothing
ErrorExit:
    Exit Sub
ErrorHandler:
    MsgBox "Error in CmdSearch() " & vbCrLf & _
           "Number: " & Err.Number & vbCrLf & _
           "Description: " & Err.Description & vbCrLf & _
           "Line Number: " & Erl()
    Err.Clear
    Resume ErrorExit
End Sub

Sub SearchForFolders(adoRST As ADODB.Recordset, strDIR As String, intCount As Integer)
On Error GoTo ErrorHandler
Dim objFSO As New FileSystemObject, fFolder As Folder, sFolder As Folder
75    Set fFolder = objFSO.GetFolder(strDIR)
76    For Each sFolder In fFolder.SubFolders
77        SearchForFolders adoRST, sFolder.Path, intCount + 1
78        With adoRST
79            .AddNew
80            !FolderID = intCount
81            !CreatedOn = Now()
82            !CreatedBy = Environ("UserName")
83            !FolderName = objFSO.GetFolder(sFolder).Name
84            !FolderPath = sFolder.Path
85            !FolderSize = objFSO.GetFolder(sFolder).Size
86            !DateCreated = objFSO.GetFolder(sFolder).DateCreated
87            !DateLastAccessed = objFSO.GetFolder(sFolder).DateLastAccessed
88            !DateLastModified = objFSO.GetFolder(sFolder).DateLastModified
89            .Update
        End With
    Next
ErrorExit:
    Exit Sub
ErrorHandler:
    MsgBox "Error in SearchForFolder() " & vbCrLf & _
           "Number: " & Err.Number & vbCrLf & _
           "Description: " & Err.Description & vbCrLf & _
           "Line Number: " & Erl()
    Err.Clear
    Resume ErrorExit
End Sub

GeneralRe: Visual Basic: Do Until i = 1 To LastFolderFound - Adding a new record Number Pin
_Erik_3-Mar-11 0:32
_Erik_3-Mar-11 0:32 
AnswerRe: Visual Basic: Do Until i = 1 To LastFolderFound - Adding a new record Number Pin
Luc Pattyn2-Mar-11 1:39
sitebuilderLuc Pattyn2-Mar-11 1:39 
GeneralRe: Visual Basic: Do Until i = 1 To LastFolderFound - Adding a new record Number Pin
Memphis762-Mar-11 6:25
Memphis762-Mar-11 6:25 
GeneralRe: Visual Basic: Do Until i = 1 To LastFolderFound - Adding a new record Number Pin
Luc Pattyn2-Mar-11 6:29
sitebuilderLuc Pattyn2-Mar-11 6:29 
AnswerRe: Visual Basic: Do Until i = 1 To LastFolderFound - Adding a new record Number Pin
Dave Kreskowiak2-Mar-11 9:28
mveDave Kreskowiak2-Mar-11 9:28 
GeneralRe: Visual Basic: Do Until i = 1 To LastFolderFound - Adding a new record Number Pin
Memphis762-Mar-11 12:05
Memphis762-Mar-11 12:05 
QuestionBIFF7 Conversion Pin
Dominick Marciano1-Mar-11 10:13
professionalDominick Marciano1-Mar-11 10:13 
AnswerRe: BIFF7 Conversion Pin
Dave Kreskowiak1-Mar-11 15:11
mveDave Kreskowiak1-Mar-11 15:11 
GeneralRe: BIFF7 Conversion Pin
Thomas Krojer1-Mar-11 21:23
Thomas Krojer1-Mar-11 21:23 
QuestionIntercept e Send ALT+F1 Pin
starcomsis1-Mar-11 5:24
starcomsis1-Mar-11 5:24 
AnswerRe: Intercept e Send ALT+F1 Pin
Dave Kreskowiak1-Mar-11 8:58
mveDave Kreskowiak1-Mar-11 8:58 
GeneralRe: Intercept e Send ALT+F1 Pin
starcomsis1-Mar-11 9:20
starcomsis1-Mar-11 9:20 
GeneralRe: Intercept e Send ALT+F1 Pin
Dave Kreskowiak1-Mar-11 14:46
mveDave Kreskowiak1-Mar-11 14:46 
QuestionHow to set parallel port in VB programming? Pin
saathis1-Mar-11 4:22
saathis1-Mar-11 4:22 
AnswerRe: How to set parallel port in VB programming? Pin
DaveAuld1-Mar-11 4:57
professionalDaveAuld1-Mar-11 4:57 
AnswerRe: How to set parallel port in VB programming? Pin
Luc Pattyn1-Mar-11 6:10
sitebuilderLuc Pattyn1-Mar-11 6:10 
AnswerRe: How to set parallel port in VB programming? Pin
glennPattonWork32-Mar-11 21:55
professionalglennPattonWork32-Mar-11 21:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.