troubleshooting Question

Reduce Code: Any way possible

Avatar of Fordraiders
FordraidersFlag for United States of America asked on
Microsoft Access
5 Comments1 Solution378 ViewsLast Modified:
Access 2000

Can anyone see a way to reduce this code? Please

Function mcrAppendCollectedBits(strName As String, strTable As String)
' this will Update only the required fields
      Dim appAccess As New Access.Application
   '  On Error Resume Next
 Select Case strTable
      Case "DRILLBITSCL" ' BITS CLE-LINE
      appAccess.OpenCurrentDatabase "C:\Crs_iCart\Prebuilts\" & strName & ".mdb", True
      appAccess.DoCmd.OpenQuery "qryApdCollCLE"
      appAccess.CloseCurrentDatabase
      appAccess.DoCmd.Quit acQuitSaveNone
      MsgBox "Updates On " & strTable & " Complete", vbInformation, "Updated " & strTable & ""
      Case "DRILLBITSCHL" ' BITS CHICAGO LATROBE
           appAccess.OpenCurrentDatabase "C:\Crs_iCart\Prebuilts\" & strName & ".mdb", True
      appAccess.DoCmd.OpenQuery "qryApdCollCHL"
      appAccess.CloseCurrentDatabase
      appAccess.DoCmd.Quit acQuitSaveNone
      MsgBox "Updates On " & strTable & " Complete", vbInformation, "Updated " & strTable & ""
      Case "DRILLBITSW" ' BITS WESTWARD
           appAccess.OpenCurrentDatabase "C:\Crs_iCart\Prebuilts\" & strName & ".mdb", True
      appAccess.DoCmd.OpenQuery "qryApdCollW"
      appAccess.CloseCurrentDatabase
      appAccess.DoCmd.Quit acQuitSaveNone
      MsgBox "Updates On " & strTable & " Complete", vbInformation, "Updated " & strTable & ""
      Case "DRILLBITSRCL" ' REDUCED SHANL CLE-LINE
           appAccess.OpenCurrentDatabase "C:\Crs_iCart\Prebuilts\" & strName & ".mdb", True
      appAccess.DoCmd.OpenQuery "qryApdCollRCLE"
      appAccess.CloseCurrentDatabase
      appAccess.DoCmd.Quit acQuitSaveNone
      MsgBox "Updates On " & strTable & " Complete", vbInformation, "Updated " & strTable & ""
      Case "DRILLBITSRCHL" ' REDUCED SHANK CHICAGO LATROBE
           appAccess.OpenCurrentDatabase "C:\Crs_iCart\Prebuilts\" & strName & ".mdb", True
      appAccess.DoCmd.OpenQuery "qryApdCollRCHL"
      appAccess.CloseCurrentDatabase
      appAccess.DoCmd.Quit acQuitSaveNone
      MsgBox "Updates On " & strTable & " Complete", vbInformation, "Updated " & strTable & ""
      Case "DRILLBITSRW" ' REDUCED SHANK WESTWARD
    appAccess.OpenCurrentDatabase "C:\Crs_iCart\Prebuilts\" & strName & ".mdb", True
      appAccess.DoCmd.OpenQuery "qryApdCollRW"
      appAccess.CloseCurrentDatabase
      appAccess.DoCmd.Quit acQuitSaveNone
      MsgBox "Updates On " & strTable & " Complete", vbInformation, "Updated " & strTable & ""
    End Select
 
End Function
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros