Been trying this for a few days now hope someone can help me out.
I have a button on my contacts form to add a folder to my c drive with the name of my contact I upgraded to 2007 but now its not working.
In my contacts Table I have a Fields ContactsID, Company, ect
But when I click on the button it comes up with this Compile Error Method or Data member not found.
Here is the button command,
Private Sub Command249_Click()
On Error GoTo Err_Command249_Click
'Stop
Dim strDocName As String
Dim intClient As Integer
intContacts = Me.ContactsID
strDocName = "Sites"
'If contact name is empty, exit sub and ask user to insert name
If Me.Company = "" Or IsNull(Me.Company) Then
MsgBox "Please insert your client name", vbCritical, "Client Missing"
Me.Company.SetFocus
Exit Sub
Else
'Assign client name to variable
intVal = 1
stClient = Me.Company
End If
'Calls Public Function to create directory
DirDets
'DoCmd.Close("Contacts")
'Open the sites form
DoCmd.OpenForm strDocName, , , , acFormAdd
Forms![Sites]![ID] = intContacts
'Call AddFloatingPane("Sites", 520, 2700)
Exit_Command249_Click:
Exit Sub
Err_Command249_Click:
MsgBox Err.Description
Resume Exit_Command249_Click
End Sub
--------------------------------------
And here is the module code Im using
--------------------------------------
Option Compare Database
Public stContacts As String
Public stSite As String
Public stPathLong As String
Public stPathMed As String
Public stFilePath As String
Public intVal As Integer
Public Function DirDets()
Select Case intVal
Case Is = 1
'if the function is callled from the Contacts form use option 1
stPathMed = defPath & stContacts & "\"
stFilePath = defPath & stContacts & "\"
Case Is = 2
'if the function is callled from the site form use option 2
stPathMed = defPath & stContacts & "\"
stFilePath = defPath & stContacts & "\" & stSite & "\"
End Select
'Check directory exists and create if prompted
CHKDIR
End Function
Public Function CHKDIR()
Dim lngRetval As Long
If Dir(stFilePath, vbDirectory) <> "" Then
' Directory exists, insert your file output code here
Else
' Directory doesn't exist
' Prompt user if he wants it to be created
lngRetval = MsgBox("Create path?", vbYesNo, "Path doesn't exist")
If lngRetval = 6 Then
' User asked to create dir, so create it.
' Well, the nested directory doesn't exist, but need
' to check if the vbtemp exists to avoid similar error
If Dir(stPathMed, vbDirectory) <> "" Then
' Just create the sub-directory
MkDir (stFilePath)
Else
If Dir(defPath, vbDirectory) <> "" Then
' Just create the Long and Medium directories
If intVal = 1 Then
MkDir (stFilePath) ' Create the long path
Else
MkDir (stPathMed) ' Create the medium path
MkDir (stFilePath) ' Create the long path
End If
Else
'Make all the directories
MkDir (defPath) ' Create the short directory
MkDir (stPathMed) ' Create the medium path
MkDir (stFilePath) ' Create the long path
End If
End If
' Check if it got created
If Dir(stFilePath, vbDirectory) <> "" Then
' Let user know it was success
MsgBox ("Path created succesfully.")
Else
' Let user know it was failure
MsgBox ("Error creating path.")
End If
Else
' User asked not to create dir
MsgBox ("Path was not created.")
End If
End If
End Function
-------------
Can someone please tell me if this is right its confusing me to hell
Thanks everyone for all the help you give
I have a button on my contacts form to add a folder to my c drive with the name of my contact I upgraded to 2007 but now its not working.
In my contacts Table I have a Fields ContactsID, Company, ect
But when I click on the button it comes up with this Compile Error Method or Data member not found.
Here is the button command,
Private Sub Command249_Click()
On Error GoTo Err_Command249_Click
'Stop
Dim strDocName As String
Dim intClient As Integer
intContacts = Me.ContactsID
strDocName = "Sites"
'If contact name is empty, exit sub and ask user to insert name
If Me.Company = "" Or IsNull(Me.Company) Then
MsgBox "Please insert your client name", vbCritical, "Client Missing"
Me.Company.SetFocus
Exit Sub
Else
'Assign client name to variable
intVal = 1
stClient = Me.Company
End If
'Calls Public Function to create directory
DirDets
'DoCmd.Close("Contacts")
'Open the sites form
DoCmd.OpenForm strDocName, , , , acFormAdd
Forms![Sites]![ID] = intContacts
'Call AddFloatingPane("Sites", 520, 2700)
Exit_Command249_Click:
Exit Sub
Err_Command249_Click:
MsgBox Err.Description
Resume Exit_Command249_Click
End Sub
--------------------------------------
And here is the module code Im using
--------------------------------------
Option Compare Database
Public stContacts As String
Public stSite As String
Public stPathLong As String
Public stPathMed As String
Public stFilePath As String
Public intVal As Integer
Public Function DirDets()
Select Case intVal
Case Is = 1
'if the function is callled from the Contacts form use option 1
stPathMed = defPath & stContacts & "\"
stFilePath = defPath & stContacts & "\"
Case Is = 2
'if the function is callled from the site form use option 2
stPathMed = defPath & stContacts & "\"
stFilePath = defPath & stContacts & "\" & stSite & "\"
End Select
'Check directory exists and create if prompted
CHKDIR
End Function
Public Function CHKDIR()
Dim lngRetval As Long
If Dir(stFilePath, vbDirectory) <> "" Then
' Directory exists, insert your file output code here
Else
' Directory doesn't exist
' Prompt user if he wants it to be created
lngRetval = MsgBox("Create path?", vbYesNo, "Path doesn't exist")
If lngRetval = 6 Then
' User asked to create dir, so create it.
' Well, the nested directory doesn't exist, but need
' to check if the vbtemp exists to avoid similar error
If Dir(stPathMed, vbDirectory) <> "" Then
' Just create the sub-directory
MkDir (stFilePath)
Else
If Dir(defPath, vbDirectory) <> "" Then
' Just create the Long and Medium directories
If intVal = 1 Then
MkDir (stFilePath) ' Create the long path
Else
MkDir (stPathMed) ' Create the medium path
MkDir (stFilePath) ' Create the long path
End If
Else
'Make all the directories
MkDir (defPath) ' Create the short directory
MkDir (stPathMed) ' Create the medium path
MkDir (stFilePath) ' Create the long path
End If
End If
' Check if it got created
If Dir(stFilePath, vbDirectory) <> "" Then
' Let user know it was success
MsgBox ("Path created succesfully.")
Else
' Let user know it was failure
MsgBox ("Error creating path.")
End If
Else
' User asked not to create dir
MsgBox ("Path was not created.")
End If
End If
End Function
-------------
Can someone please tell me if this is right its confusing me to hell
Thanks everyone for all the help you give