Results 1 to 7 of 7
  1. #1
    jpihpa is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Apr 2012
    Posts
    10

    me.city works in one line but not the next

    I have a database set up, it works perfectly in every way I need it to except for the fact that when I enter in my coding for it to create directories (folders) on our network drive it will only work partially.

    My coding is as such:

    Private Sub Combo97_AfterUpdate()
    strPath = "X:\AAA\BBB\CCC" & "\" & Me.County


    If Len(Dir(strPath, vbDirectory)) = 0 Then
    MkDir strPath
    End If

    strPath = "X:\AAA\BBB\CCC" & "\" & Me.County & "\" & Me.City
    If Len(Dir(strPath, vbDirectory)) = 0 Then
    MkDir strPath
    End If

    strPath = "X:\AAA\BBB\CCC" & "\" & Me.County & "\" & Me.City & "\" & Me.HouseNumber & IIf(IsNull(Me.StreetDirection), "", " " & Me.StreetDirection) & " " & Me.StreetName & IIf(IsNull(Me.StreetType), "", " " & Me.StreetType)
    If Len(Dir(strPath, vbDirectory)) = 0 Then
    MkDir strPath
    End If

    Shell "explorer.exe " & strPath, vbNormalFocus
    End Sub

    What it does (which I'm sure advanced users know) is that it will take the data from my fields and create a file structure out on our network drive so we can scan the documents associated with the projects into those folders for an "online library" of applications, pictures, etc. My problem is when I only have the first two strPath's it will create the County and City folders fine...but then I add the other fields to it and it gives me a method and data member not found (see right). Click image for larger version. 

Name:	Untitled.png 
Views:	23 
Size:	168.5 KB 
ID:	7861 I am just wondering if anyone would be able to help me out on this one as I have no idea why it is working for one line and then not working the next.

    Thank you for any help.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    The issue might actually be in the code that follows Me.City. Remove the code and test each piece incrementally, adding the next piece only after the other works.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    It's a bit of a shot in the dark - but try changing me.city to me!city. I've seen Access get picky about that sometimes.

    John

  4. #4
    jpihpa is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Apr 2012
    Posts
    10
    Ok. I'll give this a shot and see because it was saying that the me.housenumber wasn't working and then it said something about the me.city after that now that I think about it. For John_G, thanks for the suggestion but I tried that and it did the same thing as with Me.city...I just want this to work because I've gotten it to work on other databases. Thanks for the help from both of you and I will see if using individual pieces will help. I'll post again later today.

  5. #5
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    When I look again, I see that you have code for After Update of Combo97 - what is in combo97? Could you perhaps have forgotten to rename it to City? Which would certainly explain the error!

    Another thing to try - change

    strPath = "X:\AAA\BBB\CCC" & "\" & Me.County & "\" & Me.City & "\" & Me.HouseNumber & IIf(IsNull(Me.StreetDirection), "", " " & Me.StreetDirection) & " " & Me.StreetName & IIf(IsNull(Me.StreetType), "", " " & Me.StreetType)

    to

    strPath = strpath & "\" & Me.HouseNumber & IIf(IsNull(Me.StreetDirection), "", " " & Me.StreetDirection) & " " & Me.StreetName & IIf(IsNull(Me.StreetType), "", " " & Me.StreetType)


    John
    Last edited by John_G; 06-01-2012 at 10:59 AM. Reason: Add more text

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Good point John_G and seems so obvious now. jpihpa, make sure the controls and their procedures have the names you are using in the code.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You could also try adding a message box at the beginning of the code to check the variables:

    Code:
    Private Sub Combo97_AfterUpdate()
       Dim msg As String
    
       msg = "Me.County = " & Me.County & vbNewLine & vbNewLine
       msg = msg & "Me.City = " & Me.City & vbNewLine & vbNewLine
       msg = msg & "Me.HouseNumber = " & Me.HouseNumber & vbNewLine & vbNewLine
       msg = msg & "Me.StreetDirection = " & Me.StreetDirection & vbNewLine & vbNewLine
       msg = msg & "Me.StreetName = " & Me.StreetName & vbNewLine & vbNewLine
       msg = msg & "Me.StreetType = " & Me.StreetType
    
       MsgBox msg
    
       'The rest of the code is here
      
       End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. "Not" criteria works for one line, but not two
    By avarusbrightfyre in forum Queries
    Replies: 1
    Last Post: 02-02-2012, 10:56 AM
  2. Replies: 7
    Last Post: 08-15-2011, 05:35 AM
  3. Normalizing various City/County/State combinations (w/out zip)
    By DorkyDuvessa in forum Database Design
    Replies: 2
    Last Post: 05-08-2011, 07:49 PM
  4. City, State Zip lookup
    By garywmcp in forum Access
    Replies: 1
    Last Post: 04-24-2011, 06:15 PM
  5. Replies: 7
    Last Post: 04-11-2011, 03:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums