Results 1 to 3 of 3

Thread: [RESOLVED] Upsizing from Access 2k3 to SQL, need to change queries and macros programmatically

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2005
    Posts
    14

    Resolved [RESOLVED] Upsizing from Access 2k3 to SQL, need to change queries and macros programmatically

    As you can see from the title I am attempting to upsize an Access 2k3 database to SQL. One of the major tables has a field name that is also a SQL reserved keyword (CAGE). There are a whole lot of Queries and Macros that use this field so I am looking for an easy way to write a macro or function to search through each one and change and instances of CAGE to CAGEcode.

    I searched on here and found an example of how to change table data so I am pretty sure what I am trying to accomplish can be done.

    I don't want to reference the queries by name so I am assuming I can reference them by an index number and just cycle through.

    Any info would be greatly appreciated. Thanks!

    dingle

  2. #2
    Addicted Member
    Join Date
    Jun 2002
    Location
    Brugge, Belgium
    Posts
    208

    Re: Upsizing from Access 2k3 to SQL, need to change queries and macros programmatically

    Hello,

    I've tried this in a 2k3 access db.
    It's with DAO but works like a charm
    Code:
    Sub test()
    Dim tdf As TableDef
    Dim fld As dao.Field
    
    For Each tdf In CurrentDb.TableDefs
        For Each fld In tdf.Fields
            If InStr(1, UCase(fld.Name), "CAGE", vbTextCompare) <> 0 Then
                tdf.Fields(fld.Name).Name = "New_" & fld.Name
            End If
            
        
        Next
    
    Next
    End Sub

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2005
    Posts
    14

    Re: Upsizing from Access 2k3 to SQL, need to change queries and macros programmatically

    Quote Originally Posted by Killazzz
    Hello,

    I've tried this in a 2k3 access db.
    It's with DAO but works like a charm
    Code:
    Sub test()
    Dim tdf As TableDef
    Dim fld As dao.Field
    
    For Each tdf In CurrentDb.TableDefs
        For Each fld In tdf.Fields
            If InStr(1, UCase(fld.Name), "CAGE", vbTextCompare) <> 0 Then
                tdf.Fields(fld.Name).Name = "New_" & fld.Name
            End If
            
        
        Next
    
    Next
    End Sub

    That is exaclty what I am trying to do. Thanks for your help!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width