Access������--
ËùÊô·ÖÀࣺ ³£¼ûÎÊÌâ ×÷Õߣº kevindeng ¸üÐÂÈÕÆÚ£º2003-10-17 19:00:07 ÔĶÁ´ÎÊý£º223

ÖØж¨Î»Á´½Ó±í¶þ²½×ß


¾¡¹ÜaccxpÍøÉÏÓкܶà¹ØÓÚ¶¨Î»Á´½Ó±íµÄÌù×Ó£¬µ«»¹ÊÇÓкܶàµÄÅóÓÑѯÎÊÕâ·½ÃæµÄÎÊÌâ¡£Ó¦letterÍøÓѵÄÌáÒ飬½áºÏAlex×Ü°æÖ÷µÄÖØж¨Î»Á´½Ó±íÎļþÔ´Â룬ÏÖ½«Õâ·½ÃæµÄ¾ßÌå²Ù×÷½éÉÜÈçÏ£º

¼ÙÉèǰ̨Êý¾Ý¿âÎļþÃûΪfrontBase.mdb
ºǫ́Êý¾Ý¿âÎļþÃûΪbackData.mdb
frontBaseµ±ÖÐÓÐÁ´½Ó±ítbl1, tbl2, tbl3, ¡­£¬Á´½Óµ½backData.mdbÖÐ

Ê×ÏÈÎÒÃÇÒªÔÚǰ̨Êý¾Ý¿âÎļþµÄÆô¶¯´°Ìå¼ÓÔØʼþÖÐÅжÏÁ´½ÓÊÇ·ñÕýÈ·£¬·½·¨ÊÇ´ò¿ªÈÎÒâÒ»¸öÁ´½Ó±í£¬¼ÙÉèΪtbl1£¬´úÂëÈçÏ£º

Public Function CheckLinks() As Boolean
¼ì²éµ½ºǫ́Êý¾Ý¿âµÄÁ´½Ó£»Èç¹ûÁ´½Ó´æÔÚÇÒÕýÈ·µÄ»°£¬·µ»Ø True ¡£¡¡¡¡
¡¡¡¡Dim dbs As Database, rst As DAO.Recordset¡¡¡¡
¡¡¡¡Set dbs = CurrentDb()
¡¡¡¡ ´ò¿ªÁ´½Ó±í²é¿´±íÁ´½ÓÐÅÏ¢ÊÇ·ñÕýÈ·¡£
¡¡¡¡On Error Resume Next
¡¡¡¡Set rst = dbs.OpenRecordset(¡°tbl1¡±)
¡¡¡¡rst.Close
¡¡¡¡ Èç¹ûûÓдíÎ󣬷µ»Ø True ¡£
¡¡¡¡If Err = 0 Then
¡¡¡¡¡¡¡¡CheckLinks = True
¡¡¡¡Else
¡¡¡¡¡¡¡¡CheckLinks = False
¡¡¡¡End If¡¡¡¡
End Function

Æô¶¯´°ÌåµÄ¼ÓÔØʼþ£º
Private Sub FORM_Load()
If CheckLinks = False then
Docmd.OpenFORM ¡°frmConnect¡±
End If
End Sub

½ÓÏÂÀ´µÄÊÂÇé¾ÍÊÇÈçºÎË¢ÐÂÁ´½Ó±íÁË¡£
ÉÏÃæµÄ´°ÌåÓұߵİ´Å¥ÊÇÓÃÓÃÀ´µ÷ÓÃAPI´ò¿ªÎļþ¶Ô»°¿ò£¬¾ßÌå´úÂëÈçÏ£º
Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Boolean

Type OPENFILENAME
¡¡¡¡lStructSize As Long
¡¡¡¡hwndOwner As Long
¡¡¡¡hInstance As Long
¡¡¡¡lpstrFilter As String
¡¡¡¡lpstrCustomFilter As String
¡¡¡¡nMaxCustFilter As Long
¡¡¡¡nFilterIndex As Long
¡¡¡¡lpstrFile As String
¡¡¡¡nMaxFile As Long
¡¡¡¡lpstrFileTitle As String
¡¡¡¡nMaxFileTitle As Long
¡¡¡¡lpstrInitialDir As String
¡¡¡¡lpstrTitle As String
¡¡¡¡flags As Long
¡¡¡¡nFileOffset As Integer
¡¡¡¡nFileExtension As Integer
¡¡¡¡lpstrDefExt As String
¡¡¡¡lCustData As Long
¡¡¡¡lpfnHook As Long
¡¡¡¡lpTemplateName As String
End Type

Private Sub FileOpen_Click()
¡¡ Dim ofn As OPENFILENAME
¡¡ Dim rtn As String

¡¡ ofn.lStructSize = Len(ofn)
¡¡ ofn.hwndOwner = Me.hwnd
¡¡
¡¡ ofn.lpstrFilter = "Êý¾Ý¿âÎļþ (*.mdb)" & vbNullChar & "*.mdb"
¡¡ ofn.lpstrFile = Space(254)
¡¡ ofn.nMaxFile = 255
¡¡ ofn.lpstrFileTitle = Space(254)
¡¡ ofn.nMaxFileTitle = 255
¡¡ ofn.lpstrInitialDir = CurrentProject.Path
¡¡ ofn.lpstrTitle = "ºǫ́Êý¾ÝÎļþΪ"
¡¡ ofn.flags = 6148

¡¡ rtn = GetOpenFileName(ofn)
¡¡
¡¡ FileName.SetFocus
¡¡ If rtn = True Then
¡¡¡¡¡¡ FileName.Text = ofn.lpstrFile
¡¡¡¡¡¡ FileName.Text = FileName.Text
¡¡¡¡¡¡ OK.Enabled = True
¡¡ Else
¡¡¡¡¡¡ FileName.Text = ""
¡¡ End If
End Sub

Á¬½Ó°´Å¥Ë¢ÐÂÁ´½Ó±í£¬´úÂëÈçÏ£º
Private Sub OK_Click()
Dim tabDef As TableDef
For Each tabDef In CurrentDb.TableDefs
If Len(tabDef.Connect) > 0 Then
tabDef.Connect = ";DATABASE=" & Me.FileName.Text & ";PWD=" + ºǫ́Êý¾Ý¿âÃÜÂë
tabDef.RefreshLink
End If
Next
MsgBox "Á¬½Ó³É¹¦£¡"
DoCmd.Close acFORM, Me.Name
End Sub


ÆäʵºÜ¼òµ¥Ö»ÓÐÁ½²½£¬ÅжÏÁ´½ÓÊÇ·ñÕýÈ·ºÍË¢ÐÂÁ´½Ó±í¡£


--------------------------------------------------------------------------------
Ïà¹ØÎÄÕÂ

ACCESSµÄÊý¾Ý¿â°²È«ÎÊÌâ½â´ð 2003-11-13 10:52:11
±ÜÃâAccessºÍSQL ServerµÄ¿ÕÖµ³åÍ» 2003-10-17 20:03:19
ÌáÉýÇ°ºǫ́ģʽ³ÌÐòµÄËÙ¶È 2003-10-10 10:17:08
Access 2002 ÖеÄÃû³Æ×Ô¶¯¸üÕý˵Ã÷ 2003-10-6 15:16:24


ϵͳÓÅ»¯
¿Ø¼þʹÓÃ
Êý¾Ý¿âÉè¼Æ
Êý¾Ý¿âÁ¬½Ó
ϵͳ°²È«
OLE×Ô¶¯»¯
³£¼ûÎÊÌâ
ʵÓôúÂë
ÊôÐÔÏê½â
ÍøÂçÏà¹Ø
ʵÓÃAPI
¾­Ñé·ÖÏí
¾«Ñ¡½Ì³Ì
×Ö·û´¦Àí
ADPÏà¹Ø



ÎÄÕÂËÑË÷



ÖÆ×÷ά»¤£ºÀîÑ°»¶     Mail:[email protected]

¹ØÓÚ±¾Õ¾ -- ÍøÕ¾·þÎñ -- °æȨÌõ¿î -- ÁªÏµ·½·¨ -- ÍøÕ¾°ïÖú
Access°®ºÃÕß°æȨËùÓÐ Copyright 2003-2005 All Rights Reserved δ¾­Ðí¿É²»µÃµÁÁ´