Module to check folder existance

R

rahmad

How to wite a module to check folder " Report " exist or not.
If it doesn't exist ,then vba create one.
Later I need to keep my access pdf report to this folder
before attach it to my email.

thank's
 
R

rahmad

Dear Mr Allen,
I've read your tip ( for progammer ),but I still need guidance ( as
beginner )
Below are my code :
Dim strPath As String
Dim strModel As String
Dim strLotNo As String

strPath = Application.CurrentProject.Path
strModel = Me.Model
strLotNo = Me.LotNo

If Me.[Rotation speed No].Value = 1 Or _
Me.[Rotation speed No].Value = 4 Then
DoCmd.SetWarnings False
DoCmd.OpenQuery "Retrieved data access prt_qry", acViewNormal
DoCmd.OutputTo acOutputReport, "Electrical Report 1", acFormatSNP,
strPath & "/" & strModel & " Lot no " & strLotNo & ".snp", True
DoCmd.OpenQuery "Append email log_qry", acViewNormal
DoCmd.SetWarnings True
Else
DoCmd.SetWarnings False
DoCmd.OpenQuery "Retrieved data access prt_qry", acViewNormal
DoCmd.OutputTo acOutputReport, "Electrical Report ", acFormatSNP,
strPath & "/" & strModel & " Lot no " & strLotNo & ".snp", True
DoCmd.OpenQuery "Append email log_qry", acViewNormal
DoCmd.SetWarnings True
End If

How and where to put your code.Let say i wanna have folder 'Result' beside
my DB.
How start writing the code.
And please explain about MkDir.
If the folder does not exist, use MkDir to create it.

Thank's
 
A

Allen Browne

Hi.

I can't write your code for you.

I can suggest a FolderExists() function like this:

Function FolderExists(strPath As String) As Boolean
On Error Resume Next
FolderExists = ((GetAttr(strPath) And vbDirectory) = vbDirectory)
End Function

It goes in a Standard module. To get there, select the Modules tab of the
Database window, and click New.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

rahmad said:
Dear Mr Allen,
I've read your tip ( for progammer ),but I still need guidance ( as
beginner )
Below are my code :
Dim strPath As String
Dim strModel As String
Dim strLotNo As String

strPath = Application.CurrentProject.Path
strModel = Me.Model
strLotNo = Me.LotNo

If Me.[Rotation speed No].Value = 1 Or _
Me.[Rotation speed No].Value = 4 Then
DoCmd.SetWarnings False
DoCmd.OpenQuery "Retrieved data access prt_qry", acViewNormal
DoCmd.OutputTo acOutputReport, "Electrical Report 1", acFormatSNP,
strPath & "/" & strModel & " Lot no " & strLotNo & ".snp", True
DoCmd.OpenQuery "Append email log_qry", acViewNormal
DoCmd.SetWarnings True
Else
DoCmd.SetWarnings False
DoCmd.OpenQuery "Retrieved data access prt_qry", acViewNormal
DoCmd.OutputTo acOutputReport, "Electrical Report ", acFormatSNP,
strPath & "/" & strModel & " Lot no " & strLotNo & ".snp", True
DoCmd.OpenQuery "Append email log_qry", acViewNormal
DoCmd.SetWarnings True
End If

How and where to put your code.Let say i wanna have folder 'Result' beside
my DB.
How start writing the code.
And please explain about MkDir.
If the folder does not exist, use MkDir to create it.

Thank's


Allen Browne said:
See:
FileExists() and FolderExists() functions
at:
http://allenbrowne.com/func-11.html

If the folder does not exist, use MkDir to create it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top