實(shí)例分析Access中數(shù)據(jù)表的自動(dòng)重新聯(lián)接
Jun 07, 2016 pm 03:16 PM用Access做應(yīng)用程序,往往做成數(shù)據(jù)和程序兩個(gè)數(shù)據(jù)庫(kù),數(shù)據(jù)數(shù)據(jù)庫(kù)中只存放數(shù)據(jù)表,程序數(shù)據(jù)庫(kù)中存放所有的form,query,report,module等,通過(guò)表聯(lián)接程序數(shù)據(jù)庫(kù)可以訪問(wèn)所有數(shù)據(jù)數(shù)據(jù)庫(kù)中的表。 當(dāng)我們的應(yīng)用程序更換存儲(chǔ)位置的時(shí)候往往失去正確的表聯(lián)接,造成
用Access做應(yīng)用程序,往往做成“數(shù)據(jù)”和“程序”兩個(gè)數(shù)據(jù)庫(kù),“數(shù)據(jù)”數(shù)據(jù)庫(kù)中只存放數(shù)據(jù)表,“程序”數(shù)據(jù)庫(kù)中存放所有的form,query,report,module等,通過(guò)表聯(lián)接“程序”數(shù)據(jù)庫(kù)可以訪問(wèn)所有“數(shù)據(jù)”數(shù)據(jù)庫(kù)中的表。
當(dāng)我們的應(yīng)用程序更換存儲(chǔ)位置的時(shí)候往往失去正確的表聯(lián)接,造成運(yùn)行錯(cuò)誤。下面的一段程序可以自動(dòng)找回表聯(lián)接。在我的應(yīng)用中“程序”數(shù)據(jù)庫(kù)名字是stockMgr.mdb,“數(shù)據(jù)”數(shù)據(jù)庫(kù)名字是stock-Data.mdb。
注意: 該程序僅限于“程序”和“數(shù)據(jù)”存放在同一個(gè)目錄而且是對(duì)應(yīng)單個(gè)“數(shù)據(jù)”文件的情況。 以下為
Function ReAttachTable()<br>Dim MyDB As Database, MyTbl As TableDef<br>Dim cpath As String<br>Dim datafiles As String, i As Integer<br>On Error Resume Next<br>Set MyDB = CurrentDb<br>cpath = trimFileName(CurrentDb.Name)<br>datafiles = "stock-data.mdb"<br>DoCmd.Hourglass True<br>For i = 0 To MyDB.TableDefs.Count - 1<br>Set MyTbl = MyDB.TableDefs(i)<br>If MyTbl.Attributes = DB_ATTACHEDTABLE And Left(MyTbl.Connect, 1) = ";" Then<br>MyTbl.Connect = ";DATABASE=" & cpath & datafiles<br>MyTbl.RefreshLink<br>If Err Then<br>If vbNo = MsgBox(Err.description & ",繼續(xù)嗎?", vbYesNo) Then Exit For<br>End If<br>End If<br>Next i<br>DoCmd.Hourglass False<br>msgbox "Tables relink finish."<br>End Function<br>'絕對(duì)路徑中去掉文件名,返回路徑<br>Function trimFileName(fullname As String) As String<br>Dim slen As Long, i As Long<br>slen = Len(fullname)<br>For i = slen To 1 Step -1<br>If Mid(fullname, i, 1) = "" Then<br>Exit For<br>End If<br>Next<br>trimFileName = Left(fullname, i)<br>End Function
在程序啟動(dòng)或者按鈕動(dòng)作中調(diào)用即可。

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Web development design is a promising career field. However, this industry also faces many challenges. As more businesses and brands turn to the online marketplace, web developers have the opportunity to demonstrate their skills and succeed in their careers. However, as demand for web development continues to grow, the number of developers is also increasing, resulting in increasingly fierce competition. But it’s exciting that if you have the talent and will, you can always find new ways to create unique designs and ideas. As a web developer, you may need to keep looking for new tools and resources. These new tools and resources not only make your job more convenient, but also improve the quality of your work, thus helping you win more business and customers. The trends of web development are constantly changing.

DMA in C refers to DirectMemoryAccess, a direct memory access technology, allowing hardware devices to directly transmit data to memory without CPU intervention. 1) DMA operation is highly dependent on hardware devices and drivers, and the implementation method varies from system to system. 2) Direct access to memory may bring security risks, and the correctness and security of the code must be ensured. 3) DMA can improve performance, but improper use may lead to degradation of system performance. Through practice and learning, we can master the skills of using DMA and maximize its effectiveness in scenarios such as high-speed data transmission and real-time signal processing.

VprocesserazrabotkiveB-enclosed, Мнепришлостольностьсясзадачейтерациигооглапидляпапакробоглесхетсigootrive. LEAVALLYSUMBALLANCEFRIABLANCEFAUMDOPTOMATIFICATION, ?tookazaLovnetakProsto, Kakao?idal.Posenesko

Do you want to connect your website to Yandex Webmaster Tools? Webmaster tools such as Google Search Console, Bing and Yandex can help you optimize your website, monitor traffic, manage robots.txt, check for website errors, and more. In this article, we will share how to add your WordPress website to the Yandex Webmaster Tool to monitor your search engine traffic. What is Yandex? Yandex is a popular search engine based in Russia, similar to Google and Bing. You can excel in Yandex

How to configure Zend in Apache? The steps to configure Zend Framework in an Apache Web Server are as follows: Install Zend Framework and extract it into the Web Server directory. Create a .htaccess file. Create the Zend application directory and add the index.php file. Configure the Zend application (application.ini). Restart the Apache Web server.

Do you need to fix HTTP image upload errors in WordPress? This error can be particularly frustrating when you create content in WordPress. This usually happens when you upload images or other files to your CMS using the built-in WordPress media library. In this article, we will show you how to easily fix HTTP image upload errors in WordPress. What is the reason for HTTP errors during WordPress media uploading? When you try to upload files to Wo using WordPress media uploader

Apache server is a powerful web server software that acts as a bridge between browsers and website servers. 1. It handles HTTP requests and returns web page content based on requests; 2. Modular design allows extended functions, such as support for SSL encryption and dynamic web pages; 3. Configuration files (such as virtual host configurations) need to be carefully set to avoid security vulnerabilities, and optimize performance parameters, such as thread count and timeout time, in order to build high-performance and secure web applications.

In processing next-auth generated JWT...
