MS Query Problems - VBA to update File from Database File

QualifiedOpinion

New Member
Joined
Mar 16, 2012
Messages
2
I am loomking for an alternative to MS Query. Currently I have three workbooks. Two of the workbooks reference the third wrokbook (DataBase). The DataBase file is a simple excel database that houses data with 100 rows and 125 columns of data. All files are saved on a corporate network server (I am not technical enought to knwo what kind of server). I built a query in excel to "pull" the data into a Replica Tab in each of the other workbooks so that the data can be referenced in the two main workbooks. The process to update the replica tabs is in an open event for each file (see below). I have a few problems. One is that two people can not work in a copy of either of the two files at the same time as it will not run the open even to update the repilca tab, it says that the DataBase file is already opened. The second problem I have is that suddenly the query seems to have disappeared or is altered ni some way. The disaperance or alteration has caused the open event to fail and its' failure causes excel to crash altogether with an Excel stopped working error (resolved by opening in safe mode and removing the Macro from the open event, but now will not update my replica tab). The third problem I have is that the DataBase file at times gets "hung" open out on the server. I then have to ask my colleagues to restart their PCs so that the path that they have open closes and the file can be accessed again. This hidden open path is not closed by merely closing excel but rather a complete reboot of the PC is required. I do not have a copy of Access and doubt my organization will provide one. Is there some alternative to these problems?


Sub Refresh_DB()
'
' Refresh_DataBase Macro
'
'
'Toggle hide/unhide the DB Replica sheet for the macro to run
'the DB Replica sheet needs to be hidden at the time of file opening/macro use

Application.ScreenUpdating = False
Dim wb As Workbook
Dim ShtNames() As Variant


Set wb = ActiveWorkbook
ShtNames = Array("DB_Replica")

For i = 0 To UBound(ShtNames)
wb.Sheets(ShtNames(i)).Visible = Not wb.Sheets(ShtNames(i)).Visible
Next i
wb.Activate
Sheets("DB_Replica").Select
ActiveWorkbook.RefreshAll
wb.Activate
Sheets("Input").Select
Range("A1").Select

Application.ScreenUpdating = False


For i = 0 To UBound(ShtNames)
wb.Sheets(ShtNames(i)).Visible = Not wb.Sheets(ShtNames(i)).Visible
Next i

'
End Sub
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top