If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > DBForums Code Bank

Reply
 
LinkBack Thread Tools Display Modes
  #91 (permalink)  
Old 10-11-09, 05:19
pkstormy pkstormy is offline
Moderator
 
Join Date: Dec 2004
Location: Madison, WI
Posts: 3,925
A simple tool to view user names and passwords in an mdw file.

Extract the files in the zip and then open the Msa2kpt.mda or MSA97pt.mda depending on your version of MSAccess. Open the Msa2kpt if you have XP. It's untested against 2007.
Click the Browse button to browse to your mdw file and select it.
It will then show you a list of user names and passwords.
Attached Files
File Type: zip PasswordExtractor2000and97.zip (93.6 KB, 348 views)
__________________
Expert Database Programming
MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)
Reply With Quote
  #92 (permalink)  
Old 10-13-09, 16:43
nckdryr nckdryr is offline
Computer Monkey
 
Join Date: May 2005
Location: Oregon
Posts: 1,191
Handling Multiple Time Zones in a Database Project

When you have a database that serves people in multiple locations, you're probably going to need to store dates/times; but this then becomes an issue of controlling time and location in order to handle the varying time zones.

To get around this, I prefer to store all times in UTC, and then formatting this to local time at the user-side.

The attached database has a module that can be used both to get the current UTC time (for use when storing data), and to convert a UTC time to the local time (for use when displaying the time at the Front-End to the user). This code will automatically detect what Time Zone the user's system has selected, and will convert accordingly.

This is largely based on various bits and pieces I've found all over the internet, but I did compile and clean them up into one useful module.

EDIT:
For more information on Dates and Times in Access, see this article by Microsoft.
Attached Files
File Type: zip TimeZone.zip (15.7 KB, 62 views)
__________________
Me.Geek = True

Last edited by nckdryr; 10-13-09 at 18:31.
Reply With Quote
  #93 (permalink)  
Old 10-31-09, 03:49
chris07tibgs chris07tibgs is offline
Registered User
 
Join Date: Oct 2009
Posts: 176
I'm still a beginner, but here is my first offering...Feel free to critique, I know I need it!

All user IDs and passwords work if you put in "dbaccess"

Includes code for shift bypass, form-based login screens, password change screen and probably other stuff too
Attached Files
File Type: zip Employee Lists.zip (85.4 KB, 140 views)

Last edited by chris07tibgs; 10-31-09 at 04:14.
Reply With Quote
  #94 (permalink)  
Old 11-12-09, 14:21
pkstormy pkstormy is offline
Moderator
 
Join Date: Dec 2004
Location: Madison, WI
Posts: 3,925
Import ALL xls files into an mdb

The attachment has a routine which will take all the xls files (from the folder you select) and will import ALL those xls files (in that folder) into the mdb file automatically.

It's all menu driven so you only need to select the folder that has all the xls files and then click the import button.

Note: if you have long excel filenames you're importing, you can use the LEFT (see Importing Module) to truncate the long xls filename into shorter table names. See comments in the module: Importing Module.

(Also Note: you should copy the xls files first to a non-spaced folder but the routine will work with spaces in the folder.)

Also note: you can use this to import other files automatically as well (just change the xls to the file format you wish to import.) You may also need to change the docmd.transferspreadsheet to accommodate your import type.
Attached Files
File Type: zip ImportXLSFilesXP.zip (79.7 KB, 306 views)
__________________
Expert Database Programming
MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Last edited by pkstormy; 11-23-09 at 23:36.
Reply With Quote
  #95 (permalink)  
Old 11-24-09, 00:06
pkstormy pkstormy is offline
Moderator
 
Join Date: Dec 2004
Location: Madison, WI
Posts: 3,925
PDF creation code

Part 1 (of 3):

Here is some PDF code I found from Lebans. Perhaps someone will find it helpful:

(NOTE: I did not test this.)

'DEVELOPED AND TESTED UNDER MICROSOFT ACCESS 97 through A2003
'
'Copyright: Stephen Lebans - Lebans Holdings 1999 Ltd.


'Distribution:

' Plain and simple you are free to use this source within your own
' applications. whether private or commercial, without cost or obligation, other that keeping
' the copyright notices intact. No public notice of copyright is required.
' You may not resell this source code by itself or as part of a collection.
' You may not post this code or any portion of this code in electronic format.
' The source may only be downloaded from:
' www.lebans.com
'
'Name: ConvertReportToPDF
'
'Version: 7.51
'
'Purpose:
'
' 1) Export report to Snapshot and then to PDF. Output exact duplicate of a Report to PDF.
'
'­­­­­­­­& #173;­­­­­­­&#1 73;­­­­­­­&#173 ;­­­­­­­­& #173;­­­­­­­&#1 73;­­­­­­­&#160 ;
'
'Author: Stephen Lebans
'
'Email: Stephen@lebans.com
'
'Web Site: www.lebans.com
'
'Date: Feb 21, 2006, 11:11:11 AM
'
'Dependencies: DynaPDF.dll StrStorage.dll clsCommonDialog
'
'Inputs: See inline Comments for explanation

'Output: See inline Comments for explanation
'
'Credits: Anyone who wants some!
'
'BUGS: Please report any bugs to my email address.
'
'What's Missing:
' Enhanced Error Handling
'
'How it Works:
' A SnapShot file is created in the normal manner by code like:
' 'Export the selected Report to SnapShot format
' DoCmd.OutputTo acOutputReport, rptName, "SnapshotFormat(*.snp)", _
' strPathandFileName
'
' rptName is the desired Report we are working with.
' strPathandFileName can be anything, in this Class it is a
' Temporary FileName and Path created with calls to the
' GetTempPath and GetUniqueFileName API's.
'
' We then pass the FileName to the SetupDecompressOrCopyFile API.
' This will decompress the original SnapShot file into a
' Temporary file with the same name but a "tmp" extension.
'
' The decompressed Temp SnapShot file is then passed to the
' ConvertUncompressedSnapshotToPDF function exposed by the StrStorage DLL.
' The declaration for this call is at the top of this module.
' The function uses the Structured Storage API's to
' open and read the uncompressed Snapshot file. Within this file,
' there is one Enhanced Metafile for each page of the original report.
' Additionally, there is a Header section that contains, among other things,
' a copy of the Report's Printer Devmode structure. We need this to
' determine the page size of the report.

'The StrStorage DLL exposes one function.
'Public Function ConvertUncompressedSnapshotToPDF( _
'UnCompressedSnapShotName As String, _
'OutputPDFname As String = "", _
'Optional CompressionLevel As Long = 0, _
'Optional PasswordOwner As String = "" _
'Optional PasswordOpenAs String = "" _
'Optional PasswordRestrictions as Long = 0, _
'Optional PDFNoFontEmbedding As Long = 0 _
') As Boolean

' Now we call the ConvertUncompressedSnapshotToPDF funtion exposed by the StrStorage DLL.
'
'blRet = ConvertUncompressedSnapshot(sFileName as String, sPDFFileName as String)
'
'
'Have Fun!
'
'
'
' ************************************************** ****



Public Declare Function ConvertUncompressedSnapshot Lib "StrStorage.dll" _
(ByVal UnCompressedSnapShotName As String, _
ByVal OutputPDFname As String, _
Optional ByVal CompressionLevel As Long = 0, _
Optional ByVal PasswordOwner As String = "", _
Optional ByVal PasswordOpen As String = "", _
Optional ByVal PasswordRestrictions As Long = 0, _
Optional PDFNoFontEmbedding As Long = 0 _
) As Boolean

' For debugging with Visual C++
'Lib "C:\VisualCsource\Debug\StrStorage.dll"

Private Declare Function ShellExecuteA Lib "shell32.dll" _
(ByVal hWnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Declare Function LoadLibrary Lib "kernel32" _
Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long

Private Declare Function FreeLibrary Lib "kernel32" _
(ByVal hLibModule As Long) As Long

Private Declare Function GetTempPath Lib "kernel32" _
Alias "GetTempPathA" (ByVal nBufferLength As Long, _
ByVal lpBuffer As String) As Long

Private Declare Function GetTempFileName _
Lib "kernel32" Alias "GetTempFileNameA" _
(ByVal lpszPath As String, _
ByVal lpPrefixString As String, _
ByVal wUnique As Long, _
ByVal lpTempFileName As String) As Long

Private Declare Function SetupDecompressOrCopyFile _
Lib "setupAPI" _
Alias "SetupDecompressOrCopyFileA" ( _
ByVal SourceFileName As String, _
ByVal TargetFileName As String, _
ByVal CompressionType As Integer) As Long

Private Declare Function SetupGetFileCompressionInfo _
Lib "setupAPI" _
Alias "SetupGetFileCompressionInfoA" ( _
ByVal SourceFileName As String, _
TargetFileName As String, _
SourceFileSize As Long, _
DestinationFileSize As Long, _
CompressionType As Integer _
) As Long


'Compression types
Private Const FILE_COMPRESSION_NONE = 0
Private Const FILE_COMPRESSION_WINLZA = 1
Private Const FILE_COMPRESSION_MSZIP = 2

Private Const Pathlen = 256
Private Const MaxPath = 256


' Allow user to set FileName instead
' of using API Temp Filename or
' popping File Dialog Window
Private mSaveFileName As String

' Full path and name of uncompressed SnapShot file
Private mUncompressedSnapFile As String

' Name of the Report we ' working with
Private mReportName As String

' Instance returned from LoadLibrary calls
Private hLibDynaPDF As Long
Private hLibStrStorage As Long
__________________
Expert Database Programming
MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Last edited by pkstormy; 11-24-09 at 00:10.
Reply With Quote
  #96 (permalink)  
Old 11-24-09, 00:06
pkstormy pkstormy is offline
Moderator
 
Join Date: Dec 2004
Location: Madison, WI
Posts: 3,925
Part 2:





Public Function ConvertReportToPDF( _
Optional RptName As String = "", _
Optional SnapshotName As String = "", _
Optional OutputPDFname As String = "", _
Optional ShowSaveFileDialog As Boolean = False, _
Optional StartPDFViewer As Boolean = True, _
Optional CompressionLevel As Long = 0, _
Optional PasswordOwner As String = "", _
Optional PasswordOpen As String = "", _
Optional PasswordRestrictions As Long = 0, _
Optional PDFNoFontEmbedding As Long = 0 _
) As Boolean


' RptName is the name of a report contained within this MDB
' SnapshotName is the name of an existing Snapshot file
' OutputPDFname is the name you select for the output PDF file
' ShowSaveFileDialog is a boolean param to specify whether or not to display
' the standard windows File Dialog window to select an exisiting Snapshot file
' CompressionLevel - not hooked up yet
' PasswordOwner - not hooked up yet
' PasswordOpen - not hooked up yet
' PasswordRestrictions - not hooked up yet
' PDFNoFontEmbedding - Do not Embed fonts in PDF. Set to 1 to stop the
' default process of embedding all fonts in the output PDF. If you are
' using ONLY - any of the standard Windows fonts
' using ONLY - any of the standard 14 Fonts natively supported by the PDF spec
'The 14 Standard Fonts
'All version of Adobe's Acrobat support 14 standard fonts. These fonts are always available
'independent whether they're embedded or not.
'Family name PostScript name Style
'Courier Courier fsNone
'Courier Courier-Bold fsBold
'Courier Courier-Oblique fsItalic
'Courier Courier-BoldOblique fsBold + fsItalic
'Helvetica Helvetica fsNone
'Helvetica Helvetica-Bold fsBold
'Helvetica Helvetica-Oblique fsItalic
'Helvetica Helvetica-BoldOblique fsBold + fsItalic
'Times Times-Roman fsNone
'Times Times-Bold fsBold
'Times Times-Italic fsItalic
'Times Times-BoldItalic fsBold + fsItalic
'Symbol Symbol fsNone, other styles are emulated only
'ZapfDingbats ZapfDingbats fsNone, other styles are emulated only




Dim s As String
Dim blRet As Boolean
' Let's see if the DynaPDF.DLL is available.
blRet = LoadLib()
If blRet = False Then
' Cannot find DynaPDF.dll or StrStorage.dll file
Exit Function
End If

On Error GoTo ERR_CREATSNAP

Dim strPath As String
Dim strPathandFileName As String
Dim strEMFUncompressed As String

Dim sOutFile As String
Dim lngRet As Long

' Init our string buffer
strPath = Space(Pathlen)

'Save the ReportName to a local var
mReportName = RptName

' Let's kill any existing Temp SnapShot file
If Len(mUncompressedSnapFile & vbNullString) > 0 Then
Kill mUncompressedSnapFile
mUncompressedSnapFile = ""
End If

' If we have been passed the name of a Snapshot file then
' skip the Snapshot creation process below
If Len(SnapshotName & vbNullString) = 0 Then

' Make sure we were passed a ReportName
If Len(RptName & vbNullString) = 0 Then
' No valid parameters - FAIL AND EXIT!!
ConvertReportToPDF = ""
Exit Function
End If

' Get the Systems Temp path
' Returns Length of path(num characters in path)
lngRet = GetTempPath(Pathlen, strPath)
' Chop off NULLS and trailing "\"
strPath = Left(strPath, lngRet) & Chr(0)

' Now need a unique Filename
' locked from a previous aborted attemp.
' Needs more work!
strPathandFileName = GetUniqueFilename(strPath, "SNP" & Chr(0), "snp")

' Export the selected Report to SnapShot format
DoCmd.OutputTo acOutputReport, RptName, "SnapshotFormat(*.snp)", _
strPathandFileName
' Make sure the process has time to complete
DoEvents

Else
strPathandFileName = SnapshotName

End If

' Let's decompress into same filename but change type to ".tmp"
'strEMFUncompressed = Mid(strPathandFileName, 1, Len(strPathandFileName) - 3)
'strEMFUncompressed = strEMFUncompressed & "tmp"
Dim sPath As String * 512
lngRet = GetTempPath(512, sPath)

strEMFUncompressed = GetUniqueFilename(sPath, "SNP", "tmp")

lngRet = SetupDecompressOrCopyFile(strPathandFileName, strEMFUncompressed, 0&)

If lngRet <> 0 Then
Err.Raise vbObjectError + 525, "ConvertReportToPDF.SetupDecompressOrCopyFile" , _
"Sorry...cannot Decompress SnapShot File" & vbCrLf & _
"Please select a different Report to Export"
End If

' Set our uncompressed SnapShot file name var
mUncompressedSnapFile = strEMFUncompressed

' Remember to Cleanup our Temp SnapShot File if we were NOT passed the
' Snapshot file as the optional param
If Len(SnapshotName & vbNullString) = 0 Then
Kill strPathandFileName
End If


' Do we name output file the same as the input file name
' and simply change the file extension to .PDF or
' do we show the File Save Dialog
If ShowSaveFileDialog = False Then

' let's decompress into same filename but change type to ".tmp"
' But first let's see if we were passed an output PDF file name
If Len(OutputPDFname & vbNullString) = 0 Then
sOutFile = Mid(strPathandFileName, 1, Len(strPathandFileName) - 3)
sOutFile = sOutFile & "PDF"
Else
sOutFile = OutputPDFname
End If

Else
' Call File Save Dialog
sOutFile = fFileDialog()
If Len(sOutFile & vbNullString) = 0 Then
Exit Function
End If

End If

' Call our function in the StrStorage DLL
' Note the Compression and Password params are not hooked up yet.
blRet = ConvertUncompressedSnapshot(mUncompressedSnapFile, sOutFile, _
CompressionLevel, PasswordOwner, PasswordOpen, PasswordRestrictions, PDFNoFontEmbedding)

If blRet = False Then
Err.Raise vbObjectError + 526, "ConvertReportToPDF.ConvertUncompressedSnaphot ", _
"Sorry...damaged SnapShot File" & vbCrLf & _
"Please select a different Report to Export"
End If

' Do we open new PDF in registered PDF viewer on this system?
If StartPDFViewer = True Then
ShellExecuteA Application.hWndAccessApp, "open", sOutFile, vbNullString, vbNullString, 1
End If

' Success
ConvertReportToPDF = True


EXIT_CREATESNAP:

' Let's kill any existing Temp SnapShot file
'If Len(mUncompressedSnapFile & vbNullString) > 0 Then
On Error Resume Next
Kill mUncompressedSnapFile
mUncompressedSnapFile = ""
'End If

' If we aready loaded then free the library
If hLibStrStorage <> 0 Then
hLibStrStorage = FreeLibrary(hLibStrStorage)
End If

If hLibDynaPDF <> 0 Then
hLibDynaPDF = FreeLibrary(hLibDynaPDF)
End If

Exit Function

ERR_CREATSNAP:
MsgBox Err.Description, vbOKOnly, Err.Source & ":" & Err.Number
mUncompressedSnapFile = ""
ConvertReportToPDF = False
Resume EXIT_CREATESNAP

End Function
__________________
Expert Database Programming
MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)
Reply With Quote
  #97 (permalink)  
Old 11-24-09, 00:09
pkstormy pkstormy is offline
Moderator
 
Join Date: Dec 2004
Location: Madison, WI
Posts: 3,925
Part 3:

Private Function LoadLib() As Boolean
Dim s As String
Dim blRet As Boolean

On Error Resume Next

LoadLib = False

' If we aready loaded then free the library
If hLibDynaPDF <> 0 Then
hLibDynaPDF = FreeLibrary(hLibDynaPDF)
End If


' Our error string
s = "Sorry...cannot find the DynaPDF.dll file" & vbCrLf
s = s & "Please copy the DynaPDF.dll file to your Windows System32 folder or into the same folder as this Access MDB."

' OK Try to load the DLL assuming it is in the Window System folder
hLibDynaPDF = LoadLibrary("DynaPDF.dll")
If hLibDynaPDF = 0 Then
' See if the DLL is in the same folder as this MDB
' CurrentDB works with both A97 and A2K or higher
hLibDynaPDF = LoadLibrary(CurrentDBDir() & "DynaPDF.dll")
If hLibDynaPDF = 0 Then
MsgBox s, vbOKOnly, "MISSING DynaPDF.dll FILE"
LoadLib = False
Exit Function
End If
End If


' Our error string
s = "Sorry...cannot find the StrStorage.dll file" & vbCrLf
s = s & "Please copy the StrStorage.dll file to your Windows System32 folder or into the same folder as this Access MDB."

' ** Commented out for Debugging only - Must be active
' ************************************************** *************************
'
' OK Try to load the DLL assuming it is in the Window System folder
hLibStrStorage = LoadLibrary("StrStorage.dll")
If hLibStrStorage = 0 Then
' See if the DLL is in the same folder as this MDB
' CurrentDB works with both A97 and A2K or higher
hLibStrStorage = LoadLibrary(CurrentDBDir() & "StrStorage.dll")
If hLibStrStorage = 0 Then
MsgBox s, vbOKOnly, "MISSING StrStorage.dll FILE"
Exit Function
End If
End If


' RETURN SUCCESS
LoadLib = True
End Function


'******************** Code Begin ****************
'Code courtesy of
'Terry Kreft & Ken Getz
'
Private Function CurrentDBDir() As String
Dim strDBPath As String
Dim strDBFile As String
strDBPath = CurrentDb.Name
strDBFile = Dir(strDBPath)
CurrentDBDir = Left$(strDBPath, Len(strDBPath) - Len(strDBFile))
End Function
'******************** Code End ****************



Private Function GetUniqueFilename(Optional path As String = "", _
Optional Prefix As String = "", _
Optional UseExtension As String = "") _
As String

' originally Posted by Terry Kreft
' to: comp.Databases.ms -Access
' Subject: Re: Creating Unique filename ??? (Dev code)
' Date: 01/15/2000
' Author: Terry Kreft <terry.kreft@mps.co.uk>

' SL Note: Input strings must be NULL terminated.
' Here it is done by the calling function.

Dim wUnique As Long
Dim lpTempFileName As String
Dim lngRet As Long

wUnique = 0
If path = "" Then path = CurDir
lpTempFileName = String(MaxPath, 0)
lngRet = GetTempFileName(path, Prefix, _
wUnique, lpTempFileName)

lpTempFileName = Left(lpTempFileName, _
InStr(lpTempFileName, Chr(0)) - 1)
Call Kill(lpTempFileName)
If Len(UseExtension) > 0 Then
lpTempFileName = Left(lpTempFileName, Len(lpTempFileName) - 3) & UseExtension
End If
GetUniqueFilename = lpTempFileName
End Function


Private Function fFileDialog() As String
' Calls the API File Save Dialog Window
' Returns full path to new File

On Error GoTo Err_fFileDialog

' Call the File Common Dialog Window
Dim clsDialog As Object
Dim strTemp As String
Dim strFname As String

Set clsDialog = New clsCommonDialog

' Fill in our structure
' I'll leave in how to select Gif and Jpeg to
' show you how to build the Filter in case you want
' to use this code in another project.
clsDialog.Filter = "PDF (*.PDF)" & Chr$(0) & "*.PDF" & Chr$(0)
'clsDialog.Filter = clsDialog.Filter & "Gif (*.GIF)" & Chr$(0) & "*.GIF" & Chr$(0)
'clsDialog.Filter = "ALL (*.*)" & Chr$(0) & "*.*" & Chr$(0)
clsDialog.hDC = 0
clsDialog.MaxFileSize = 256
clsDialog.Max = 256
clsDialog.FileTitle = vbNullString
clsDialog.DialogTitle = "Please Select a path and Enter a Name for the PDF File"
clsDialog.InitDir = vbNullString
clsDialog.DefaultExt = vbNullString

' Display the File Dialog
clsDialog.ShowSave

' See if user clicked Cancel or even selected
' the very same file already selected
strFname = clsDialog.FileName
'If Len(strFname & vbNullString) = 0 Then
' Raise the exception
' Err.Raise vbObjectError + 513, "clsPrintToFit.fFileDialog", _
'"Please type in a Name for a New File"
'End If

' Return File Path and Name
fFileDialog = strFname

Exit_fFileDialog:

Err.Clear
Set clsDialog = Nothing
Exit Function

Err_fFileDialog:
fFileDialog = ""
MsgBox Err.Description, vbOKOnly, Err.Source & ":" & Err.Number
Resume Exit_fFileDialog

End Function




Public Function fFileDialogSnapshot() As String
' Calls the API File Open Dialog Window
' Returns full path to existing Snapshot File

On Error GoTo Err_fFileDialog

' Call the File Common Dialog Window
Dim clsDialog As Object
Dim strTemp As String
Dim strFname As String

Set clsDialog = New clsCommonDialog

' Fill in our structure
' I'll leave in how to select Gif and Jpeg to
' show you how to build the Filter in case you want
' to use this code in another project.
clsDialog.Filter = "SNAPSHOT (*.SNP)" & Chr$(0) & "*.SNP" & Chr$(0)
'clsDialog.Filter = "ALL (*.*)" & Chr$(0) & "*.*" & Chr$(0)
clsDialog.hDC = 0
clsDialog.MaxFileSize = 256
clsDialog.Max = 256
clsDialog.FileTitle = vbNullString
clsDialog.DialogTitle = "Please Select a Snapshot File"
clsDialog.InitDir = vbNullString
clsDialog.DefaultExt = vbNullString

' Display the File Dialog
clsDialog.ShowOpen

' See if user clicked Cancel or even selected
' the very same file already selected
strFname = clsDialog.FileName
If Len(strFname & vbNullString) = 0 Then
' Do nothing. Add your desired error logic here.
End If

' Return File Path and Name
fFileDialogSnapshot = strFname

Exit_fFileDialog:

Err.Clear
Set clsDialog = Nothing
Exit Function

Err_fFileDialog:
fFileDialogSnapshot = ""
MsgBox Err.Description, vbOKOnly, Err.Source & ":" & Err.Number
Resume Exit_fFileDialog

End Function



Public Function fFileDialogSavePDFname() As String
' Calls the API File Open Dialog Window
' Returns full path to existing Snapshot File

On Error GoTo Err_fFileDialog

' Call the File Common Dialog Window
Dim clsDialog As Object
Dim strTemp As String
Dim strFname As String

Set clsDialog = New clsCommonDialog

' Fill in our structure
' I'll leave in how to select Gif and Jpeg to
' show you how to build the Filter in case you want
' to use this code in another project.
clsDialog.Filter = "PDF (*.PDF)" & Chr$(0) & "*.PDF" & Chr$(0)
'clsDialog.Filter = "ALL (*.*)" & Chr$(0) & "*.*" & Chr$(0)
clsDialog.hDC = 0
clsDialog.MaxFileSize = 256
clsDialog.Max = 256
clsDialog.FileTitle = vbNullString
clsDialog.DialogTitle = "Please Select a name for the PDF File"
clsDialog.InitDir = vbNullString
clsDialog.DefaultExt = vbNullString



' Display the File Dialog
clsDialog.ShowOpen

' See if user clicked Cancel or even selected
' the very same file already selected
strFname = clsDialog.FileName
If Len(strFname & vbNullString) = 0 Then
' Do nothing. Add your desired error logic here.
End If

' Return File Path and Name
fFileDialogSavePDFname = strFname

Exit_fFileDialog:

Err.Clear
Set clsDialog = Nothing
Exit Function

Err_fFileDialog:
fFileDialogSavePDFname = ""
MsgBox Err.Description, vbOKOnly, Err.Source & ":" & Err.Number
Resume Exit_fFileDialog

End Function
__________________
Expert Database Programming
MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)
Reply With Quote
  #98 (permalink)  
Old 11-24-09, 00:40
pkstormy pkstormy is offline
Moderator
 
Join Date: Dec 2004
Location: Madison, WI
Posts: 3,925
Hyperlinks and opening web pages via vba code

Example 1:
- To shell to a folder in windows explorer (not web related in this example - just shows how you can open a folder using the shell command):
Shell "C:\WINDOWS\explorer.exe """ & Me!ExportFolderName & "", vbNormalFocus

Example 2:
- To open a webpage by supplying the URLAddress
Dim objXMLHTTP, xml
Set xml = Nothing
Set xml = CreateObject("Microsoft.XMLHTTP")
xml.Open "POST", URLAddress, False
xml.send Data

Example 3:
- To pass parameters to a webpage and open it (this example opens google-map to get directions by passing the address.)

If IsNull(Me!Address1) Or IsNull(Me!City) Or IsNull(Me!State) Then
MsgBox "You must first enter the Address, City, and State!"
Exit Sub
End If
Dim dAddr As Variant
Dim Addr As Variant
Dim SAddr As Variant
Select Case Me!CenterID '<= ie. if it's Madison (case 2), return directions to the Madison location, otherwise to the Milwaukee location (case 3).
Case 2
dAddr = "1930+Monroe+St+Madison+WI+(The+Monroe+Buildin g+Su ite+200)"
Case 3
dAddr = "+848+N+12th+Milwaukee+WI+(Parking+Garage+Entr ance )"
End Select
'SAddr = Addr1 & "+" & Addr2 & "+" & City & "+" & State 'commented out - but left for example.
SAddr = Me!Address1 & "+" & Me!City & "+" & Me!State
'SAddr = Replace(Addr, " ", "+") & "+" 'commented out - but left for example.

strurl = "http://maps.google.com/maps?f=d&hl=en&geocode=&saddr=" & SAddr & "&daddr=" & dAddr & "&pw=2"

Application.FollowHyperlink strurl
__________________
Expert Database Programming
MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Last edited by pkstormy; 11-24-09 at 00:45.
Reply With Quote
  #99 (permalink)  
Old 02-08-10, 09:32
pkstormy pkstormy is offline
Moderator
 
Join Date: Dec 2004
Location: Madison, WI
Posts: 3,925
Calendar Report

This is a calendar report very nicely designed by Poppa Smurf.

You can select a start/end date and then preview/print/email the report in a nice and helpful calendar type view. Allows automatic expansion of days where there are a lot of appointments.
Attached Files
File Type: zip CalendarReport.zip (36.8 KB, 129 views)
__________________
Expert Database Programming
MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)
Reply With Quote
  #100 (permalink)  
Old 03-21-10, 04:43
pkstormy pkstormy is offline
Moderator
 
Join Date: Dec 2004
Location: Madison, WI
Posts: 3,925
Unbound form example (basic)

Here's a very basic example of an unbound form and code to write to/from the form. There are different techniques and this is only one of many (written in ADO code).

I had some problems with it erroring in MSAccess 2003 (it may be due to me having both 2003 and 2007 on the same computer) but it works fine in 2007.

You'll need to look at the Module: Customer Functions to see the functions which do the actual writing/retrieving/updating of the data. I reference the form directly in these functions but there are other ways.

If you're embedding a subform (such as a continuous one), I'd set this subform bound to the relational table (with criteria in the recordsource so CustomerID = Forms!CustomerForm!CustomerID) and then issue a Forms!CustomerForm.requery in the appropriate functions after the record has been retrieved. Creating unbound continous subforms gets a bit involved if they are continuous. Otherwise you could use the same principles as above for the Customerform if it's a single form (ie. Forms!CustomerForm!CustomerFormSub!CustomerID = rs!CustomerID, etc...etc... for your subform field names).
Attached Files
File Type: zip UnboundFormExample.zip (27.1 KB, 92 views)
__________________
Expert Database Programming
MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Last edited by pkstormy; 03-21-10 at 04:52.
Reply With Quote
  #101 (permalink)  
Old 03-27-10, 11:28
Sinndho Sinndho is online now
Registered User
 
Join Date: Mar 2009
Posts: 3,107
pkstormy,

I'm not sure that my RegEx example is worth an entry in the library, but here you are.

The project needs a reference to the Microsoft VBScript Regular Expressions 5.5. This library is part of Internet Explorer 5.5 (and later), so it should be available on all computers running Windows XP, Vista, or 7, as well as any computer with IE 5.5 or later installed (meaning almost every Windows PC that is used to connect to the Internet).

I've included five functions using regular expressions:

- RegExReplace works like the standard Replace function but with regular expressions in the Search parameter. That was the initial example I provided on the forum.

- RegExLike performs a comparison between a string and another that can contain a regular expression. It works a bit as the LIKE operator but LIKE can only evaluate a limited subset of regular expressions, so:
Code:
Panel = "ZB-E10-P522"
Debug.Print RegExLike(Panel, "\-P.*")
is very similar to:
Code:
Panel = "ZB-E10-P522"
Debug.Print Eval("'" & Panel & "' Like '*-P*'")
- RegExMatch returns True if one or more occurences of a sting that can contain a regular expression is found in another string, so:
Code:
Panel = "ZB-E10-P522"
Debug.Print RegExMatch(Panel, "\-P.*")
can be compared with:
Code:
Panel = "ZB-E10-P522"
Debug.Print Instr(Panel, "-P") <> 0
- RegExMatches returns the number of occurences a sting that can contain a regular expression is found in another string.

- RegExInStr is similar to the InStr function. It returns the position of the first occurence a sting that can contain a regular expression is found in another string.

All functions are not case-sensitive by default but an optional boolean parameter (IgnoreCase) can be set to False to make them case-sensitive.

These functions are just wrappers (black boxes?) hiding the different properties and methods of the RegExp class, and in most cases using an instance of that class is as easy as using them. Perhaps they are easier for someone that's not familiar with object-oriented programing and feels more at ease with "classical" functions.

Credits are due to the author of the site:
Regular-Expressions.info - Regex Tutorial, Examples and Reference - Regexp Patterns
This is where the idea of using a reference to the RegExp class comes from.
Attached Files
File Type: zip RegEx.zip (13.5 KB, 37 views)
__________________
Have a nice day!
Reply With Quote
  #102 (permalink)  
Old 03-30-10, 18:40
Sinndho Sinndho is online now
Registered User
 
Join Date: Mar 2009
Posts: 3,107
Another implementation of a Drag-and-Drop mechanism between two list boxes.

Maybe it's only me, but I've searched (and found) several examples of how to implement a Drag-and-Drop mechanism in a form. These examples were generally good, some of them were even brilliant, however I found most of them hard to understand and hard to use.

Recently, I had to debug a rather ancient program where such a mechanism was used, because after a minor modification that someone else did the program stopped working as expected. This modification had nothing to do with the Drag-and-Drop functionalities that were used, but as I had to execute the code step by step, I was lead from one module to another, simply because the implementation of the D-n-D functionalities used many functions spread among different modules, with a reference to the form passed along among them (Ex. in the form: StartDrag Me, in the StartDrag function (located in another module): If IsRegistered(frmCaller) then... 'frmCaller is the reference to the form received by StartDrag and IsRegistered is another function somewhere else, etc.).

I finally decided to write a tutorial about a simple and documented system to implement Drag-and-Drop functionalities on a form and to supply a sample database to illustrate it.

Both files (the documentation and the database) can be found in the attached .zip file. The document is in pdf format and the database was created with Access 2003 (SP 3) in Access 2000 format.
Attached Files
File Type: zip ListDragDrop.zip (188.7 KB, 89 views)
__________________
Have a nice day!

Last edited by Sinndho; 04-01-10 at 19:09.
Reply With Quote
  #103 (permalink)  
Old 05-03-10, 20:53
pkstormy pkstormy is offline
Moderator
 
Join Date: Dec 2004
Location: Madison, WI
Posts: 3,925
Color Transition example.

A neat way to make a form with colors that blend from one side of the form to the other.

Note: it will prompt you for your first/last name when you open the mdb. It automatically recognizes your loginID and will save this information (along with your color settings) to a 'user' type table (called: dbo_Users).

You can customize any colors you want.
Attached Files
File Type: zip ColorTransitionExample.zip (207.7 KB, 76 views)
__________________
Expert Database Programming
MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)
Reply With Quote
  #104 (permalink)  
Old 09-06-10, 03:37
pkstormy pkstormy is offline
Moderator
 
Join Date: Dec 2004
Location: Madison, WI
Posts: 3,925
How to disable MSAccess Menu items, any version

The following is a simple technique on how to disable users from clicking on any of the MSAccess Menu items.

I use this technique to control what users can/cannot click on.

It basically involves opening a 'background' form, maximizing it, and then opening a popup/modal type form after that.

Notice in the example that you cannot click on any of the MSAccess menu items. You can thus control the flow of how user's open forms and what they can/cannot click on by designing popup/modal type forms.


Simple but effective.

.

(note: if you have problems opening the zip file in this attachment, see the following posts)
http://www.accessforums.net/code-rep...html#post30756
http://forums.aspfree.com/microsoft-...tml#post818265
http://www.utteraccess.com/forum/Dis...l#entry2020068

Also make sure your intranet security settings in IE have this website as a trusted website.
Attached Files
File Type: zip DisableMSAccessMenus.zip (18.5 KB, 52 views)
__________________
Expert Database Programming
MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Last edited by pkstormy; 09-06-10 at 03:41.
Reply With Quote
  #105 (permalink)  
Old 09-06-10, 03:47
pkstormy pkstormy is offline
Moderator
 
Join Date: Dec 2004
Location: Madison, WI
Posts: 3,925
Open a folder, supplying the folder/subfolder name

This example shows how you can enter a folder/subfolder name into a text box and then open that folder.

You could utilize this example if, for example, you had multiple subfolders each named as an 'account number' or 'customer number' and you wanted to enter a specific number and quickly open that folder.

As you'll see, the code is very simple (only about 8 lines of code.)
Attached Files
File Type: zip OpenFolderEx.zip (10.8 KB, 45 views)
__________________
Expert Database Programming
MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


LinkBacks (?)
LinkBack to this Thread: http://www.dbforums.com/microsoft-access/1605962-dbforums-code-bank.html
Posted By For Type Date
Problem opening file, Error 3197 Post #0 Refback 08-11-10 17:45
Access 2003 - how to pass data from one from to an other Post #0 Refback 08-08-10 08:20
MSACCESS.exe has problems that MSARN200.exe doesn't - Page 2 Post #0 Refback 08-07-10 22:00
How to provide security to the database and source code? Post #0 Refback 08-03-10 12:52
User Level Security eliminated? Post #0 Refback 08-03-10 11:40
Developer Gone Cannot Access Database Structure Post #0 Refback 08-03-10 11:40
Force users to log off Post #0 Refback 08-03-10 10:54
Login form register Post #0 Refback 08-02-10 15:56
How to TRULY lock access to tables Post #0 Refback 08-02-10 09:22
Access to SQL Post #0 Refback 08-02-10 04:18
Locked for editing Post #0 Refback 08-02-10 03:27
open a secure database Post #0 Refback 08-02-10 02:18
Newbie : Need Information on Migrating Data to SQL This thread Pingback 08-02-10 01:03
Weighted-average inventory costing. This thread Refback 08-01-10 23:42
Find (and go to) a record.. - Access World Forums Post #0 Refback 07-29-10 15:18
Find (and go to) a record.. - Access World Forums Post #0 Refback 07-29-10 12:28
How to Not sync 5 tables in a 4 set replica? - Access World Forums This thread Refback 07-16-10 14:07
Appointment Reminder by Phone - UtterAccess Discussion Forums This thread Refback 06-26-10 11:44
How to Not sync 5 tables in a 4 set replica? - Access World Forums This thread Refback 05-26-10 08:45
Question Optimizing form on load - Access World Forums Post #0 Refback 05-19-10 14:26
Sidebar menu flyout - Access World Forums Post #0 Refback 05-18-10 19:26
Point of sale software - Access World Forums This thread Refback 05-13-10 04:01
Question Optimizing form on load - Access World Forums Post #0 Refback 05-12-10 15:39
How to link and display task based on user login - Access World Forums Post #0 Refback 05-09-10 04:56
replicated & non-replicated tables - Page 2 - Access World Forums Post #0 Refback 05-08-10 16:22
replicated & non-replicated tables - Page 2 - Access World Forums Post #0 Refback 05-08-10 04:00
Point of sale software - Access World Forums This thread Refback 05-07-10 06:37
Question Multiple FE connections - odd problem to solve. - Access World Forums Post #0 Refback 05-05-10 22:28
Point of sale software - Access World Forums This thread Refback 05-04-10 14:26
Question Optimizing form on load - Access World Forums Post #0 Refback 05-04-10 13:17
Question Export to Text File Error - Access World Forums Post #0 Refback 05-04-10 12:57
Question Export to Text File Error - Access World Forums Post #0 Refback 05-03-10 21:20
Killing locks and sessions in access - Access World Forums Post #0 Refback 05-03-10 16:16
How to link and display task based on user login - Access World Forums Post #0 Refback 05-03-10 15:25
Point of sale software - Access World Forums This thread Refback 05-03-10 13:01
Point of sale software - Access World Forums This thread Refback 05-03-10 06:40
Open different forms when in runtime - Access World Forums Post #0 Refback 05-03-10 06:21
Killing locks and sessions in access - Access World Forums Post #0 Refback 05-03-10 03:55
Point of sale software - Access World Forums This thread Refback 05-03-10 02:46
Question Export to Text File Error - Access World Forums Post #0 Refback 05-03-10 00:30
Question User level security - retrieving group membership - Access World Forums Post #0 Refback 05-02-10 00:39
Point of sale software - Access World Forums This thread Refback 05-01-10 19:49
Question User level security - retrieving group membership - Access World Forums Post #0 Refback 05-01-10 19:39
Sidebar menu flyout - Access World Forums Post #0 Refback 05-01-10 17:54
Sidebar menu flyout - Access World Forums Post #0 Refback 05-01-10 17:18
Open different forms when in runtime - Access World Forums Post #0 Refback 05-01-10 10:26
???? - jetutil.dll This thread Refback 04-30-10 11:03
belajar-access : Messages : 26142-26158 of 26582 Post #0 Refback 04-27-10 23:34
RE: [belajar-access] [Tanya] tal?Merubah Kotak Pesan (msgbox) Post #0 Refback 04-16-10 13:40
Re: [belajar-access] [Tanya] tal?Merubah Kotak Pesan (msgbox) Post #0 Refback 04-13-10 00:48
Hide Access and show only my forms Post #0 Refback 03-29-10 16:49
UtterAccess Discussion Forums - User-Level Security Question Post #0 Refback 12-11-09 12:59
user notification - Access World Forums Post #0 Refback 11-19-09 07:25
Finding the location of a database - Access World Forums Post #0 Refback 10-29-09 08:04
CodeProject: MS Access - Active Directory Role Membership. Free source code and programming help Post #0 Refback 08-08-09 02:17
CodeProject: MS Access - Active Directory Role Membership. Free source code and programming help Post #0 Refback 07-23-09 00:56
UtterAccess Discussion Forums - User-Level Security Question Post #0 Refback 06-01-09 19:16
UtterAccess Discussion Forums - User-Level Security Question Post #0 Refback 04-16-09 14:47
Microsoft: Access Forms - Updating Frontend Post #0 Refback 04-16-09 08:22
Microsoft: Access Forms - Updating Frontend Post #0 Refback 03-16-09 09:41
Microsoft: Access Forms - Updating Frontend Post #0 Refback 03-09-09 05:03
Crosstab values - Access World Forums This thread Refback 01-15-09 12:40