尝试访问远程项目中表单模块的代码行

问题描述

我正在尝试列出远程 MS Access 项目中所有过程的代码行。标准或类模块没有问题,但是当我访问表单时,我无法访问它们的模块属性

KeyError                                  Traceback (most recent call last)
~\anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self,key,method,tolerance)
   2645             try:
-> 2646                 return self._engine.get_loc(key)
   2647             except KeyError:

pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'Neighborhood'

During handling of the above exception,another exception occurred:

KeyError                                  Traceback (most recent call last)
<ipython-input-109-7784a05c5fcd> in <module>
----> 1 toronto_venues = getNearbyVenues(names=df['Neighborhood'],latitudes=df['Latitude'],longitudes=df['Longitude'])

~\anaconda3\lib\site-packages\pandas\core\frame.py in __getitem__(self,key)
   2798             if self.columns.nlevels > 1:
   2799                 return self._getitem_multilevel(key)
-> 2800             indexer = self.columns.get_loc(key)
   2801             if is_integer(indexer):
   2802                 indexer = [indexer]

~\anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self,tolerance)
   2646                 return self._engine.get_loc(key)
   2647             except KeyError:
-> 2648                 return self._engine.get_loc(self._maybe_cast_indexer(key))
   2649         indexer = self.get_indexer([key],method=method,tolerance=tolerance)
   2650         if indexer.ndim > 1 or indexer.size > 1:

pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'Neighborhood'

解决方法

要获取表单的模块,您需要在设计视图中打开表单。

For Each xObj In appAccess.CurrentProject.AllForms
    appAccess.DoCmd.OpenForm xObj.Name,1 '1 = acDesign
    Debug.Print appAccess.Forms(xObj.Name).Module.Lines(1,10000) 'Print the first 10K lines
    'If you want to print all lines with no maximum,use `Module.CountOfLines` to get the count
    appAccess.DoCmd.Close 2,xObj.Name '2 = acForm
Next