I am using Access 2007 on a PC running Windows Vista.
The Access database with VBA code in many modules works as expected. However, one module acts differently after I have exited the database and re-entered. As soon as I re-enter, I can select View Code and Save without changing any code and the program goes back to working the way I expected. Any ideas?
Details:
The Access module with the inconsistency opens Word 2007 and creates a new document from a template (.dotx) file using bookmarks to merge Access data into the document. This works as designed without a problem and works every time. Once the document is created, the vba code calls the Word window to front. This does not happen unless I select View Code and Save. I do not have to modify any code, just select Save. Then it works as expected until I close the database. When I next open the database and select the button that creates the Word document, the document is not brought to front but remains behind the Access window. If I select View Code and Save, the subsequent documents created during that session come to front as desired. This is consistent and repeatable.
I am not sure about why this is occurring, but a quick fix that I thought might work would be to programmatically save the module when you load your DB.
docmd.save acmodule, "module name"
Hope this works!
Related
In my database (Access 2013, .accdw), I am checking the user's current version in the Form_Open event. If it is not up to date it triggers an external command to download a fresh copy and then is supposed to close itself to allow for the update. The problem is that after Application.Quit is triggered, access closes but instantly reopens, blocking the download. I've stripped out all the code I can to isolate the problem.
If 1 = 1 Then
Application.Quit
End If
Simplified pretty far, right? It should always just close as soon as the form is opened. With this as the only code in my Form_Open event which is the only code in the form, it still closes, reopens, and then closes again. Docmd.Quit has the same effect. I've tried too many variations to enumerate. In a button this code works fine, but I need it to run the check before it loads any data (the linked tables may be being altered while we change versions).
Any ideas how to make it stay closed the first time it closes?
I think it reopens because your external code (.bat file ?) reopens it. It's not an Access problem. Have you checked the numerous tools you can find for Access automated client deployment ? Here are the first 2 I found:
http://www.databasejournal.com/features/msaccess/article.php/3286111/Automatically-Deploy-a-New-Access-Client.htm
http://www.devhut.net/2015/06/30/ms-access-deploying-your-database-front-end-to-your-users/
Your code works for me in a Form_Open(), but then this is Access 2010 and no Sharepoint.
You may have better luck by Creating an AutoExec macro that calls an initialization function that does the version check, instead of having a form open automatically.
If the version check is ok, then open your start form from the function.
The easy work-around is to always fetch the current version and then launch it.
This way there's no fuzz and the user always run the latest version.
Ok, I'm creating a Word document (based on a template) from MS Access and updating several charts by using the OLEFormat object. Once I .Activate the object, which creates a new instance of Excel, and make my edits, I close that instance of Excel with:
wdChart.ChartData.Workbook.Application.Quit
This works fine if there are no other instances of Excel running. But, if there is an open instance of Excel when the OLEFormat.Activate happens, it doesn't create a new instance of Excel, but opens the chart spreadsheet in the same instance of Excel that is open. So when I execute the .Application.Quit command, it closes ALL open workbooks in that instance and prompts me to save the workbook. At this point, I get a Word message that says:
To insert a chart, you must first close any open dialog boxes or
cancel editing mode in Microsoft Excel
The my code fails with a:
Method 'Activate' of object 'ChartData' failed
I think these errors have to do with the fact that my code is sequentially editing several charts. When the Word dialog pops up, my code is still trying to run or something.
I think what would solve all of this is if there is a way to force the OLEFormat.Activate to open it's own instance of Excel. Is this possible?
You need to check to see if there are more than 1 workbooks open. If so, then close the chart workbook, otherwise, quit the application.
If wdChart.ChartData.Workbook.Application.Workbooks.Count > 1 Then
wdChart.ChartData.Workbook.Close saveChanges:=False
Else
wdChart.ChartData.Workbook.Application.Quit
End If
I had a similar issue with this and with "AddChart", for some reason in Office 2010(not 2013 or 2016) sometimes when accessing multiple charts in a row the excel windows doesn't close before another one opens. This causes the error that #MultiGuy experienced.
I my case I just added a small wait time in front of my "Activate" and "AddChart" calls and it seems to have resolved the issue:
Excel.Application.Wait Now + TimeValue("0:00:01")
Long term I should probably write some sort of function that waits until the associated excel window has closed, but for now I think this much more brittle approach will work in most scenario's.
I keep commenting out my queries in the SquirreL SQL client, but I also have been opening new connections using other Aliases, however it all gets a bit crowded in the tab area.
I've also been able to save my queries in files, which works great except for the fact that the entire path to the file (often very long) appears in the tab.
Is it possible to just have another SQL tab opened, or might there be a way to simplify how many SQL query tabs I open?
I hope, the answer will be still useful, although the question is asked some times ago :-)
Is it possible to just have another SQL tab opened, or might there be a way to simplify how many SQL query tabs I open?
You can open a new SQL-Worksheet for the current session.
Try one of the following:
Shortcut CTRL+N
Menu Session >> New SQL-Worksheet
In the toolbar, the icon right of the rollback button.
I've also been able to save my queries in files, which works great except for the fact that the entire path to the file (often very long) appears in the tab.
This changed in 3.4.0. Please see the changes
Instead of displaying the file paths in Session tabs a small button is displayed when an open file exists.
Clicking the button will open a popup menu that gives access to several information and functions concerning the file.
MS Access 2010, Win 7 on a regular formI didn't intentionally place any ActiveX or OLE things.. not even sure what they are. But anyways, whenever I put something in the code of a particular form, it says "The Expression XXXXX you entered as the event property setting produced the following error: A problem occured while MyDB was communicating with the OLE server or Active X Control
Huh? No matter what I put in the form's code, this happens. I had an empty Form_Current() ONLY which still tripped this. There's a lot of formatting and work into the form, I'd rather not scrap it.. If I leave the code window completely empty (only Option Compare Database), it does not trip the error; however then my form is useless.
I've seen things about this being a language issue, but my other forms (running the same code techniques and most of the same code) are fine and it's an english Access with an english language PC. Ideas?
Code setting off the error:
Private Sub Form_Current()
End Sub
Seriously.
I faced the same problem and I tried many things, the only (and fastest) solution that worked is to do the following:
1) Close the form that is causing the error.
2) Rename this form.
3) Duplicate it: Copy, then Paste, you will be prompted to set a name for the new form. Give it the original name.
4) Delete the original form that was causing the error.
5) Open the pasted form and it will work OK.
This solution worked fine with my database...
Regards...
Check for missing references. Make a back-up, decompile, compact & repair and if that does not work, copy everything to a new db ( http://www.granite.ab.ca/access/corruptmdbs.htm ) You may have to skip copying the problem form. Sometimes it is worth creating a new form, selecting all the controls from the old form and pasting into the new form.
you can change the language setting to have a try, the steps are as follow:
1、Open window command ,run "intl.cpl"
2、choose the Administrative item ,change the system locale settings.
Hope that can help you.
I have run into this problem many times. The error statement is horrible as it provides basically no useful information. I have found that Abu Hassan's solution typically works best (duplicate the form and delete the original) but that did not work for me on one occasion, where I had to delete an import statement that I had recently added:
imports system.collections
Once I deleted that import statement everything worked again. So if duplicating the form doesn't work then try undoing something you recently did. It could be this import statement or one similar to it.
Very strange error, that sometimes occurs in my databases too.
It seems to go wrong mostly on UNBOUND FORMS (unbound forms have no RECORDSOURCE).
What I have done recently is :
temporarily define "some" table (e.g. a config table with just one record) as the RecordSource,
compile the program (Note that this usually goes OK, even before the fix!)
Save the form.
Open the form. This should work fine now!
Delete the RecordSource, recompile and save again.
Most of the time, my forms work fine again after that.
as my experience some of errors because you use your local language in VBA statement
so you must adjust your local language as language of system from control banal >> language or region>>administrative>>change system local then select your local languages
or find the word was not English in vba and retype it by English
I have a legacy app I am currently supporting that is having problems when people copy large quantities of data from a datasheet view.
The App is built in MS Access and the amount of rows being copied can get pretty large (sometimes in the thousands).
The funny thing about it is, you can paste the data out, but then Access keeps "rendering" the data into different formats and becomes CPU bound for LONG periods of time.
The Status message beside the progress bar at the bottom right of the MS Access Window is
Rendering Data to format: Biff5
Biff5 is a "Binary Interchange File Format (BIFF) version 5" According to Source
The app code doesn't use BIFF5 anywhere so I don't think this is an app problem.
I cannot find any data on this error anywhere on the web so I thought it would be a good question for stackoverflow.
So, can anyone help please?
Instead of trying to copy-paste, can't you just export the query to Excel?
I am not sure what the problem is but sometimes you can run into some very quirky bugs with Access. Have you tried running this on different machines? Different OS's? Would it be possible to paste the data into Excel and then import into Access using import functionality? Can you import the data directly instead of pasting it?
Try copy-paste operation through VBA:
Once user has selected data to copy, you can execute the code below when click on a button in the form, and then do a pastespecial in excel:
--- Data selected by user ---
RunCommand acCmdCopy
Dim xlApp As Object
Set xlApp = CreateObject(Class:="Excel.Application")
'New Excel Workbook
Dim xlWbook As Object 'Excel.Workbook
Set xlWbook = xlApp.Workbooks.Add
'Paste in excel
xlWSheet.Range("A1").Select
xlWSheet.PasteSpecial Link:=False, DisplayAsIcon:=False, Format:="Biff5"
We are all on the same OS here for this, I am investigating the possibility that some update sent out in the last maintenance window has caused this, as it wasn't a problem before this and there have been no new releases of the software in that time period.
Tried in on lot's of machines, same issue on them all.
The problem is actually with copying from a datasheet view in Access and pasting to Excel, not the other way around strangely.
Here is the use case
Access --> "Copy from datasheet"(Normal Ctrl+C) --> "paste into Excel" (Normal Ctrl+V)
(this works fine!)
When you then go back to Access to continue working, it is CPU bound doing the "Rendering Data to format: " thing, I mentioned above.
I'm stumped to be honest, it's all a bit strange.