Results 1 to 4 of 4
  1. #1
    Abacus1234 is offline Competent Performer
    Windows Vista Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    212

    Working query stops working after importing

    I have narrowed down the problem I wrote about earlier.

    I have 2 queries that reference a field called CombineNamesAddresses$("CloseForm","Seller").

    If I copy the current database and import these 2 queries from the current database to a copy of the current database everything works the way I want it to.

    If I import the 2 queries into a new empty database and then import into the copy of the current database, both queries give me this message. Undefined function "[CombineNamesAddress[" If I remove those fields from the query, everything else works the way I want it to.

    As I have imported these queries before without having this problem, I am flummoxed.


    [CODE]Function CombineName(FormName$, BaseNameEx$)

    'Combine the name fields on FormName$.BaseNameEx$ as definedfor
    'CombineNamesAddresss

    Dim TempName$

    ' If Not(IsNull(Forms(FormName$)(BaseNameEx$ + "Prefix"))) Then
    ' TempName$ = Forms(FormName$)(BaseNameEx$ +"Prefix")
    ' Else
    TempName$ =""
    ' End If

    If Not(IsNull(Forms(FormName$)(BaseNameEx$ + "FName"))) Then
    If TempName$<> "" Then TempName$ = TempName$ + " "
    TempName$ =TempName$ + Forms(FormName$)(BaseNameEx$ + "FName")
    End If

    ' If Not(IsNull(Forms(FormName$)(BaseNameEx$ + "Initials"))) Then
    ' If TempName$ <> "" ThenTempName$ = TempName$ + " "
    ' TempName$ = TempName$ +Forms(FormName$)(BaseNameEx$ + "Initials")
    ' End If

    If Not(IsNull(Forms(FormName$)(BaseNameEx$ + "LName"))) Then
    If TempName$<> "" Then TempName$ = TempName$ + " "
    TempName$ =TempName$ + Forms(FormName$)(BaseNameEx$ + "LName")
    End If

    'If Not(IsNull(Forms(FormName$)(BaseNameEx$ + "Suffix"))) Then
    ' If TempName$ <> "" ThenTempName$ = TempName$ + " "
    ' TempName$ = TempName$ +Forms(FormName$)(BaseNameEx$ + "Suffix")
    'End If

    If TempName$ ="" Then
    CombineName = Null
    Else
    CombineName =TempName$
    End If



    End Function

    Function CombineNamesAddresses$(FormName$, BaseName$)

    '
    'Combines upto 4 names and addresses with BaseName on Form$.
    'Each address is combined to a single line.
    'Names without an address are attached to the previous name.
    'Duplicate addresses (for sequential entries) are treated asname only above.
    '
    'The name consists of these fields (all prefixed withBaseName$):
    'Prefix FName Initials LName Suffix
    '
    'Likewise the address consists of:
    'Add City State Zip
    ''Add' is converted to a single line.

    Dim Name1, Name2,Name3, Name4 As Variant
    Dim Addr1, Addr2,Addr3, Addr4 As Variant
    Dim Full$


    'Build all the names
    Name1 =CombineName(FormName$, BaseName$ + "1")
    Name2 =CombineName(FormName$, BaseName$ + "2")
    Name3 =CombineName(FormName$, BaseName$ + "3")
    Name4 =CombineName(FormName$, BaseName$ + "4")

    '...and theaddresses
    Addr1 =CombineAddress(FormName$, BaseName$ + "1")
    Addr2 =CombineAddress(FormName$, BaseName$ + "2")
    Addr3 =CombineAddress(FormName$, BaseName$ + "3")
    Addr4 =CombineAddress(FormName$, BaseName$ + "4")

    'Pad out blank addresses
    If IsNull(Addr1)Then Addr1 = ""
    If IsNull(Addr2)Then Addr2 = Addr1
    If IsNull(Addr3)Then Addr3 = Addr2
    If IsNull(Addr4)Then Addr4 = Addr3

    'Combine names withthe same address
    If Not(IsNull(Name1) Or IsNull(Name2) Or IsNull(Addr1)) Then
    If (Addr2 = Addr1)Then 'Second same as first
    Name1 = Name1 +" & " + Name2
    Name2 = Null
    End If
    End If
    If Not(IsNull(Name3) Or IsNull(Name4) Or IsNull(Addr3)) Then
    If (Addr4 = Addr3)Then
    Name3 = Name3 +" & " + Name4
    Name4 = Null
    End If
    End If

    Full$ = ""
    If Not(IsNull(Name1)) Then Full$ = Name1 + ", " + Addr1
    If Not(IsNull(Name2)) Then
    If Full$ <>"" Then Full$ = Full$ + Chr(13) + Chr(10)
    Full$ = Full$ + Name2+ ", " + Addr2
    End If
    If Not(IsNull(Name3)) Then
    If Full$ <>"" Then Full$ = Full$ + Chr(13) + Chr(10)
    Full$ = Full$ +Name3 + ", " + Addr3
    End If
    If Not(IsNull(Name4)) Then
    If Full$ <>"" Then Full$ = Full$ + Chr(13) + Chr(10)
    Full$ = Full$ +Name4 + ", " + Addr4
    End If

    CombineNamesAddresses$ = Full$

    End Function
    [/CODE]

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Those queries don't reference a field, they call a custom function. That function also has to be imported into the new db.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Abacus1234 is offline Competent Performer
    Windows Vista Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    212
    Its already in the new database. Are you saying it needs to be in the temporary database with the query? thanks for the response. I'm in the middle of translating the custom function into a series of fields in the query so that I can do without it. But still I do not understand if there is some kind of evaluation going on in the temporary database.

    I have at last been able to make the temporary (update) database that I have been trying to make. But I have to put some tables in the temporary database to make this happen. I do not import the tables into the final destination. They are just used as some kind of reference for the objects in the temporary database. Really don't understand why just know it works that way.
    Last edited by Abacus1234; 10-25-2015 at 02:13 PM.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Glad you got it sorted.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Append Query Stops Working in RunSQL Command Question
    By McArthurGDM in forum Programming
    Replies: 6
    Last Post: 06-11-2015, 11:17 AM
  2. Access stops working and reloads
    By Simgene in forum Programming
    Replies: 4
    Last Post: 12-26-2014, 03:28 PM
  3. find (ctrl + F) stops working
    By mad4mp3z in forum Access
    Replies: 2
    Last Post: 04-07-2014, 12:19 PM
  4. Code stops working after restarting?!?!
    By tonybrecko in forum Access
    Replies: 3
    Last Post: 06-22-2013, 09:14 AM
  5. Having - Like stops working
    By tdalber in forum Queries
    Replies: 0
    Last Post: 02-03-2009, 04:30 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