Please Help Error After Upgrading to 2007

extreme

Registered User.
Local time
Today, 12:00
Joined
Sep 27, 2004
Messages
51
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
 
Comment out your

On Error GoTo Err_Command249_Click

so then it will give you a DEBUG button and then by clicking it you will be taken to the offending code. Then we can talk.
 
Thanks for the quick reply

done what you said remove On Error GoTo Err_Command249_Click

it gives me a ok or cancel button but it just stops the debuger

I clicked on help it gave me this


Method or data member not found (Error 461)

The collection, object, or user-defined type doesn't contain the referenced member. This error has the following causes and solutions:


You misspelled the object or member name.
Check the spelling of the names and check the Type statement or the object documentation to determine what the members are and the proper spelling of the object or member names.

You specified a collection index that's out of range.
Check the Count property to determine whether a collection member exists. Note that collection indexes begin at 1 rather than zero, so the Count property returns the highest possible index number.
 
You need to prefix your objects with a common naming convention like txt for a text box.

What is stClient = Me.Company ? I do not see where you have declared stClient as a string?

Is Company the name of the field in the table or the name of a text box? Again, use a naming convention to help identify your object.
 
Thanks for the reply I will check back through it to see
 

Users who are viewing this thread

Back
Top Bottom