When you right a program in other languages you can send arguments into that program when you run the executable. Is there a way to feed information into and Access file so that it can be retrieved once the access Database is loaded.
I don't know if this is what you're looking for, but you can run an AutExec macro that fires on database load- this could be used to run whatever code you want to import or load data??
Nigel
Didn't someone say work is supposed to be fun? They didn't have computers then I guess....
Const ERR_NOSECTIONSTRING = "No section was specified. Function aborted."
Const ERR_NOKEYNAMESTRING = "No key name was specified. Function aborted."
Const DEFAULT_VALUE = "<NULL>"
Private Declare Function GetPrivateProfileString Lib "Kernel32.dll" Alias "GetPrivateProfileStringA" ( _
ByVal lpAppName As String, _
ByVal lpKeyName As String, _
ByVal lpDefault As String, _
ByVal lpReturnedString As String, _
ByVal nSize As Integer, _
ByVal lpFileName As String _
) As Integer
Private Declare Function GetPrivateProfileKeys Lib "Kernel32.dll" Alias "GetPrivateProfileStringA" ( _
ByVal lpAppName As String, _
ByVal lpKeyName As Long, _
ByVal lpDefault As String, _
ByVal lpReturnedString As String, _
ByVal nSize As Integer, _
ByVal lpFileName As String _
) As Integer
Private Declare Function GetPrivateProfileSectionNames Lib "Kernel32.dll" Alias "GetPrivateProfileSectionNamesA" ( _
ByVal lpReturnBuffer As String, _
ByVal nSize As Long, _
ByVal lpFileName As String _
) As Long
Private m_sFilename As String
Private m_cData As Collection
Property Get Filename() As String
Filename = m_sFilename
End Property
Property Let Filename(s As String)
m_sFilename = s
parse
End Property
Private Function GetKeyValue(ByVal sSectionName As String, ByVal sKeyName As String) As String
On Error GoTo e_Handler
'dims
Dim hr As Long
Dim sBuf As String
Dim lSize As Long
'default buffer size
lSize = 128
'first things first, we really need a section name here
If Len(sSectionName) = 0 Then
Err.Raise ERR_BASE + ERR_NOSECTION, , ERR_NOSECTIONSTRING
ElseIf Len(sKeyName) = 0 Then
Err.Raise ERR_BASE + ERR_NOKEYNAME, , ERR_NOKEYNAMESTRING
End If
Do
'default buffer size
sBuf = Space$(lSize)
'call the API to get the key value
hr = GetPrivateProfileString(sSectionName, sKeyName, DEFAULT_VALUE, sBuf, Len(sBuf), m_sFilename)
'see API documentation for more info, suffice to say if the return val is size-1 then buffer was too small
If hr = lSize - 1 Then
'increase buffer size
lSize = lSize * 2
Else
'success
lSize = 0
End If
'if lSize <> 0 then needs to loop again
Loop While lSize
'trim null chars
sBuf = Left$(sBuf, hr)
'return the value
GetKeyValue = sBuf
Exit Function
e_Handler:
'do nothing
Exit Function
End Function
Property Get KeyNames(ByVal sSectionName As String) As Variant
On Error GoTo e_Handler
'dims
Dim hr As Long
Dim sBuf As String
Dim lSize As Long
'default buffer size
lSize = 128
'first things first, we really need a section name here, throw error if not available
If Len(sSectionName) = 0 Then
sBuf = Space$(lSize)
hr = GetPrivateProfileKeys(sSectionName, 0, "", sBuf, Len(sBuf), m_sFilename)
'since key name will always be null we're looking for an hr = size - 2
If hr = lSize - 2 Then
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.