|
Почему не работает функция iif в Access 2000
|
|||
---|---|---|---|
#18+
Объясните пожалуйста: 1. Почему функция Text = iif(Me.Sb1, Me.Sb1, ““) - работает в Access 2.0, - не работает в Access 2000? 2. Где проверка условия в первом Me.Sb1 3. Почему после изменения функции Text = iif(Me!Sb1 <> ““, Me.Sb1, ““) она заработала и в Access 2000. !!! Обратите внимание, что по отношению к примеру приведенному в пункте 1 (Access 2.0) в Access 2000достаточно было произвести ТОЛЬКО два изменения и ОБА - при проверке условия: - заменить Me.Sb1 на Me!Sb1 (точка заменена на восклицательный знак) - поставить оператор проверки <> ““ ... |
|||
:
Нравится:
Не нравится:
|
|||
23.03.2004, 09:05 |
|
Почему не работает функция iif в Access 2000
|
|||
---|---|---|---|
#18+
вообще-то первый аргумент функции логическое выражение. строковое выражение вряд ли может быть преобразовано в логическое. отсюда и неправильная работа функции. то, что она в таком виде работала в 2, говорит лишь о том, что там использовалось преобразовние по умолчанию текст->логика. а в 2000 его убили. и это правильно. ... |
|||
:
Нравится:
Не нравится:
|
|||
23.03.2004, 10:17 |
|
Почему не работает функция iif в Access 2000
|
|||
---|---|---|---|
#18+
Проблемма с "."<=>"!" при переходе с 2.0 будет возникать очень часто, потому что в новом синтаксесе более строго отделены поля от методов. Я в свое время написал транслятор ищущий в модулях и запросах лексемы объектов с . и заменяющий их на ! Посмотри может пригодится 'Модуль по изменению модулей Function FindAndReplace(mdl As Module, strSearchText As String, _ strNewText As String) As Boolean Dim lngSLine As Long, lngSCol As Long Dim lngELine As Long, lngECol As Long Dim strLine As String, strNewLine As String Dim intChr As Integer, intBefore As Integer, _ intAfter As Integer Dim strLeft As String, strRight As String ' Open module. 'DoCmd.OpenModule strModuleName ' Return reference to Module object. 'Set mdl = Modules(strModuleName) lngSLine = 0 lngSCol = 0 lngELine = 0 lngECol = 0 ' Search for string. Do While mdl.Find(strSearchText, lngSLine, lngSCol, lngELine, lngECol) ' Store text of line containing string. strLine = mdl.Lines(lngSLine, Abs(lngELine - lngSLine) + 1) ' Determine length of line. intChr = Len(strLine) ' Determine number of characters preceding search text. intBefore = lngSCol - 1 ' Determine number of characters following search text. intAfter = intChr - CInt(lngECol - 1) ' Store characters to left of search text. strLeft = Left$(strLine, intBefore) ' Store characters to right of search text. strRight = Right$(strLine, intAfter) ' Construct string with replacement text. strNewLine = strLeft & strNewText & strRight ' Replace original line. mdl.ReplaceLine lngSLine, strNewLine 'FindAndReplace = True lngSCol = lngSCol + 1 lngELine = 0 lngECol = 0 Loop ' Else ' MsgBox "Text not found." ' FindAndReplace = False ' End If Exit_FindAndReplace: Exit Function Error_FindAndReplace: MsgBox Err & ": " & Err.Description FindAndReplace = False Resume Exit_FindAndReplace End Function Function GetModuleName() As Integer Dim i As Integer, sSQL As String 'Modules(2).Name For i = 0 To Application.CurrentProject.AllModules.Count - 1 sSQL = "INSERT INTO Модули ( ID, Name ) SELECT " & i & ",'" & Application.CurrentProject.AllModules(i).Name & "'" CurrentDb().Execute sSQL Next i GetModuleName = Application.CurrentProject.AllModules.Count End Function Function SetFormControlsName() As Integer Dim i As Integer, j As Integer Dim MyObj As Object Dim frm As Form Dim rcs As Recordset Set MyObj = Application.CurrentProject.AllForms For i = 0 To MyObj.Count - 1 DoCmd.OpenForm MyObj(i).Name, acDesign Set frm = Forms(MyObj(i).Name) For j = 0 To frm.Count - 1 If frm(j).Name = "Filter" Then frm(j).Name = "strFilter" End If Next j DoCmd.Close acForm, MyObj(i).Name, acSaveYes Next i SetFormControlsName = MyObj.Count End Function Function FindFromModulesOpenF() As Integer Dim i As Integer, j As Integer, RcsCout As Integer, sSQL As String Dim MyObj As Object Dim mdl As Module Dim lngSLine As Long, lngSCol As Long Dim lngELine As Long, lngECol As Long Dim strSearchText As String Dim strLine As String, strNewLine As String Dim intChr As Integer, intBefore As Integer, intAfter As Integer Dim strLeft As String, strRight As String Dim strRstID As String Dim rcsFormlist As Recordset sSQL = "Delete * From формы " CurrentDb().Execute sSQL 'Set rcsFormlist = CurrentDb().OpenRecordset("FormList") 'Set MyObj = Application.CurrentProject.AllModules strSearchText = "openf" RcsCout = 0 lngSLine = 0 lngSCol = 0 lngELine = 0 lngECol = 0 'For i = 0 To MyObj.Count - 1 'If "ИзменениеМодулей" <> MyObj(i).Name Then ' DoCmd.OpenModule MyObj(i).Name ' Set mdl = Modules(MyObj(i).Name) ' lngSLine = 0 ' lngSCol = 0 ' Do While mdl.Find(strSearchText, lngSLine, lngSCol, lngELine, lngECol, True) ' ' strLine = mdl.Lines(lngSLine, Abs(lngELine - lngSLine) + 1) ' intBefore = lngSCol - 1 ' If Mid(Left$(strLine, intBefore), intBefore, 1) <> " " Then ' Exit Do ' End If ' strLeft = RTrim(Left$(strLine, intBefore)) ' j = Len(strLeft) ' ' 'Поиск символа разделителя ' Do Until (Mid(strLeft, j, 1) = "," Or Mid(strLeft, j, 1) = " ") ' j = j - 1 ' Loop ' ' strRstID = Mid(strLeft, j + 1, Len(strLeft) - j) ' RcsCout = RcsCout + 1 ' ' ' If FindAndReplace(mdl, strRstID & ".", strRstID & "!") Then MsgBox "???" ' ' ' sSQL = "INSERT INTO Модули ( Key,ID, Name ) SELECT " & RcsCout & "," & i & ",'" & strRstID & "'" ' CurrentDb().Execute sSQL ' lngSCol = lngSCol + 1 ' lngELine = 0 ' lngECol = 0 ' Loop 'End If 'Next i Set MyObj = Application.CurrentProject.AllForms lngSLine = 0 lngSCol = 0 lngELine = 0 lngECol = 0 For i = 0 To MyObj.Count - 1 ' rcsFormlist.MoveFirst ' rcsFormlist.FindFirst "Name=" & MyObj(i).Name DoCmd.OpenForm MyObj(i).Name, acDesign Set mdl = Forms(MyObj(i).Name).Module lngSLine = 0 lngSCol = 0 Do While mdl.Find(strSearchText, lngSLine, lngSCol, lngELine, lngECol) strLine = mdl.Lines(lngSLine, Abs(lngELine - lngSLine) + 1) ' intBefore = lngSCol - 1 ' If Mid(Left$(strLine, intBefore), intBefore, 1) <> " " Then ' Exit Do ' End If If Mid(strLine, lngSCol + 5, 1) = "(" Then intBefore = lngSCol + 6 Else intBefore = lngSCol + 9 End If strRight = Mid(strLine, intBefore) j = InStr(strRight, ",") If j <> 0 Then strRight = Left(strRight, j - 1) strRight = Replace(strRight, """", "") 'Поиск символа разделителя ' Do Until (Mid(strLeft, j, 1) = "," Or Mid(strLeft, j, 1) = " " Or Mid(strLeft, j, 1) = "(") ' j = j - 1 ' Loop ' strRstID = Mid(strLeft, j + 1, Len(strLeft) - j) RcsCout = RcsCout + 1 sSQL = "INSERT INTO формы ( Name ) SELECT '" & strRight & "'" CurrentDb().Execute sSQL lngSCol = lngSCol + 1 lngELine = 0 lngECol = 0 Loop DoCmd.Close acForm, MyObj(i).Name, acSaveYes ' End If Next i ' 'rcsFormlist.Close FindFromModulesOpenF = RcsCout End Function Function FindFromModules() As Integer Dim i As Integer, j As Integer, RcsCout As Integer, sSQL As String Dim MyObj As Object Dim mdl As Module Dim lngSLine As Long, lngSCol As Long Dim lngELine As Long, lngECol As Long Dim strSearchText As String Dim strLine As String, strNewLine As String Dim intChr As Integer, intBefore As Integer, intAfter As Integer Dim strLeft As String, strRight As String Dim strRstID As String Dim rcsFormlist As Recordset sSQL = "Delete * From Модули " CurrentDb().Execute sSQL 'Set rcsFormlist = CurrentDb().OpenRecordset("FormList") 'Set MyObj = Application.CurrentProject.AllModules strSearchText = "As Recordset" RcsCout = 0 lngSLine = 0 lngSCol = 0 lngELine = 0 lngECol = 0 'For i = 0 To MyObj.Count - 1 'If "ИзменениеМодулей" <> MyObj(i).Name Then ' DoCmd.OpenModule MyObj(i).Name ' Set mdl = Modules(MyObj(i).Name) ' lngSLine = 0 ' lngSCol = 0 ' Do While mdl.Find(strSearchText, lngSLine, lngSCol, lngELine, lngECol, True) ' ' strLine = mdl.Lines(lngSLine, Abs(lngELine - lngSLine) + 1) ' intBefore = lngSCol - 1 ' If Mid(Left$(strLine, intBefore), intBefore, 1) <> " " Then ' Exit Do ' End If ' strLeft = RTrim(Left$(strLine, intBefore)) ' j = Len(strLeft) ' ' 'Поиск символа разделителя ' Do Until (Mid(strLeft, j, 1) = "," Or Mid(strLeft, j, 1) = " ") ' j = j - 1 ' Loop ' ' strRstID = Mid(strLeft, j + 1, Len(strLeft) - j) ' RcsCout = RcsCout + 1 ' ' ' If FindAndReplace(mdl, strRstID & ".", strRstID & "!") Then MsgBox "???" ' ' ' sSQL = "INSERT INTO Модули ( Key,ID, Name ) SELECT " & RcsCout & "," & i & ",'" & strRstID & "'" ' CurrentDb().Execute sSQL ' lngSCol = lngSCol + 1 ' lngELine = 0 ' lngECol = 0 ' Loop 'End If 'Next i Set MyObj = Application.CurrentProject.AllForms lngSLine = 0 lngSCol = 0 lngELine = 0 lngECol = 0 For i = 0 To MyObj.Count - 1 ' rcsFormlist.MoveFirst ' rcsFormlist.FindFirst "Name=" & MyObj(i).Name DoCmd.OpenForm MyObj(i).Name, acDesign Set mdl = Forms(MyObj(i).Name).Module lngSLine = 0 lngSCol = 0 Do While mdl.Find(strSearchText, lngSLine, lngSCol, lngELine, lngECol) strLine = mdl.Lines(lngSLine, Abs(lngELine - lngSLine) + 1) intBefore = lngSCol - 1 If Mid(Left$(strLine, intBefore), intBefore, 1) <> " " Then Exit Do End If strLeft = RTrim(Left$(strLine, intBefore)) j = Len(strLeft) 'Поиск символа разделителя Do Until (Mid(strLeft, j, 1) = "," Or Mid(strLeft, j, 1) = " " Or Mid(strLeft, j, 1) = "(") j = j - 1 Loop strRstID = Mid(strLeft, j + 1, Len(strLeft) - j) RcsCout = RcsCout + 1 sSQL = "INSERT INTO Модули ( Key,ID, Name ) SELECT " & RcsCout & "," & i & ",'" & strRstID & "'" CurrentDb().Execute sSQL lngSCol = lngSCol + 1 lngELine = 0 lngECol = 0 Loop DoCmd.Close acForm, MyObj(i).Name, acSaveYes ' End If Next i ' 'rcsFormlist.Close FindFromModules = RcsCout End Function Function ReplaceFromModules() As Integer Dim i As Integer Dim MyObj As Object Dim mdl As Module Dim rcs As Recordset Dim rcsFormlist As Recordset 'If FindFromModules() = 0 Then ' Beep ' Exit Function 'End If 'Set MyObj = Application.CurrentProject.AllModules Set rcs = CurrentDb().OpenRecordset("rcslist") Application.Echo False Set rcsFormlist = CurrentDb().OpenRecordset("Select Name From FormList") 'For i = 0 To MyObj.Count - 1 ' If MyObj(i).Name <> "ИзменениеМодулей" Then ' DoCmd.OpenModule MyObj(i).Name ' Set mdl = Modules(MyObj(i).Name) ' rcs.MoveFirst ' Do Until rcs.EOF ' If FindAndReplace(mdl, rcs!Name & ".", rcs!Name & "!") Then MsgBox "???" ' rcs.MoveNext ' Loop ' If FindAndReplace(mdl, "!AbsolutePosition", ".AbsolutePosition") Then MsgBox "???" ' If FindAndReplace(mdl, "!AddNew", ".AddNew") Then MsgBox "???" ' If FindAndReplace(mdl, "!BatchCollisionCount", ".BatchCollisionCount") Then MsgBox "???" ' If FindAndReplace(mdl, "!BatchCollisions", ".BatchCollisions") Then MsgBox "???" ' If FindAndReplace(mdl, "!BatchSize", ".BatchSize") Then MsgBox "???" ' If FindAndReplace(mdl, "!BOF", ".BOF") Then MsgBox "???" ' If FindAndReplace(mdl, "!Bookmark", ".Bookmark") Then MsgBox "???" ' If FindAndReplace(mdl, "!Bookmarkable", ".Bookmarkable") Then MsgBox "???" ' If FindAndReplace(mdl, "!CacheSize", ".CacheSize") Then MsgBox "???" ' If FindAndReplace(mdl, "!CacheStart", ".CacheStart") Then MsgBox "???" ' If FindAndReplace(mdl, "!Cancel", ".Cancel") Then MsgBox "???" ' If FindAndReplace(mdl, "!CancelUpdate", ".CancelUpdate") Then MsgBox "???" ' If FindAndReplace(mdl, "!Clone", ".Clone") Then MsgBox "???" ' If FindAndReplace(mdl, "!Close", ".Close") Then MsgBox "???" ' If FindAndReplace(mdl, "!Connection", ".Connection") Then MsgBox "???" ' If FindAndReplace(mdl, "!CopyQueryDef", ".CopyQueryDef") Then MsgBox "???" ' If FindAndReplace(mdl, "!DateCreated", ".DateCreated") Then MsgBox "???" ' If FindAndReplace(mdl, "!Delete", ".Delete") Then MsgBox "???" ' ' If FindAndReplace(mdl, "!Edit", ".Edit") Then MsgBox "???" ' If FindAndReplace(mdl, "!EditMode", ".EditMode") Then MsgBox "???" ' If FindAndReplace(mdl, "!EOF", ".EOF") Then MsgBox "???" ' If FindAndReplace(mdl, "!Fields", ".Fields") Then MsgBox "???" ' If FindAndReplace(mdl, "!FillCache", ".FillCache") Then MsgBox "???" ' '!!!!!!!!!!!! ' ' If FindAndReplace(mdl, "strFilter", "strstrFilter") Then MsgBox "???" ' '!!!!!!!!!!!!! ' If FindAndReplace(mdl, "!FindFirst", ".FindFirst") Then MsgBox "???" ' If FindAndReplace(mdl, "!FindLast", ".FindLast") Then MsgBox "???" ' If FindAndReplace(mdl, "!FindNext", ".FindNext") Then MsgBox "???" ' If FindAndReplace(mdl, "!FindPrevious", ".FindPrevious") Then MsgBox "???" ' ' If FindAndReplace(mdl, "!GetRows", ".GetRows") Then MsgBox "???" ' If FindAndReplace(mdl, "!Index", ".Index") Then MsgBox "???" ' If FindAndReplace(mdl, "!LastModified", ".LastModified") Then MsgBox "???" ' If FindAndReplace(mdl, "!LastUpdated", ".LastUpdated") Then MsgBox "???" ' If FindAndReplace(mdl, "!LockEdits", ".LockEdits") Then MsgBox "???" ' If FindAndReplace(mdl, "!Move", ".Move") Then MsgBox "???" ' If FindAndReplace(mdl, "!MoveFirst", ".MoveFirst") Then MsgBox "???" ' If FindAndReplace(mdl, "!MoveLast", ".MoveLast") Then MsgBox "???" ' If FindAndReplace(mdl, "!MoveNext", ".MoveNext") Then MsgBox "???" ' If FindAndReplace(mdl, "!MovePrevious", ".MovePrevious") Then MsgBox "???" ' '!!!!!!!!!!!! '' Name ' '!!!!!!!!!!!! ' ' If FindAndReplace(mdl, "!NextRecordset", ".NextRecordset") Then MsgBox "???" ' If FindAndReplace(mdl, "!NoMatch", ".NoMatch") Then MsgBox "???" ' If FindAndReplace(mdl, "!OpenRecordset", ".OpenRecordset") Then MsgBox "???" ' If FindAndReplace(mdl, "!PercentPosition", ".PercentPosition") Then MsgBox "???" ' If FindAndReplace(mdl, "!Properties", ".Properties") Then MsgBox "???" ' If FindAndReplace(mdl, "!RecordCount", ".RecordCount") Then MsgBox "???" ' If FindAndReplace(mdl, "!RecordStatus", ".RecordStatus") Then MsgBox "???" ' If FindAndReplace(mdl, "!Requery", ".Requery") Then MsgBox "???" ' If FindAndReplace(mdl, "!Restartable", ".Restartable") Then MsgBox "???" ' If FindAndReplace(mdl, "!Seek", ".Seek") Then MsgBox "???" ' If FindAndReplace(mdl, "!Sort", ".Sort") Then MsgBox "???" ' If FindAndReplace(mdl, "!StillExecuting", ".StillExecuting") Then MsgBox "???" ' If FindAndReplace(mdl, "!Transactions", ".Transactions") Then MsgBox "???" ' If FindAndReplace(mdl, "!Type", ".Type") Then MsgBox "???" ' If FindAndReplace(mdl, "!Updatable", ".Updatable") Then MsgBox "???" ' If FindAndReplace(mdl, "!Update", ".Update") Then MsgBox "???" ' If FindAndReplace(mdl, "!UpdateOptions", ".UpdateOptions") Then MsgBox "???" ' If FindAndReplace(mdl, "!ValidationRule", ".ValidationRule") Then MsgBox "???" ' If FindAndReplace(mdl, "!ValidationText", ".ValidationText") Then MsgBox "???" ' ' '!!!!!!!!!!!!! ' If FindAndReplace(mdl, "!Zvalue", ".Zvalue") Then MsgBox "???" ' If FindAndReplace(mdl, "!GNA_Name", ".GNA_Name") Then MsgBox "???" ' If FindAndReplace(mdl, "!GNA_FlU", ".GNA_FlU") Then MsgBox "???" ' If FindAndReplace(mdl, "!GNA_List", ".GNA_List") Then MsgBox "???" ' If FindAndReplace(mdl, "!Zformat", ".Zformat") Then MsgBox "???" ' If FindAndReplace(mdl, "Forms!", "Forms!") Then MsgBox "???" ' If FindAndReplace(mdl, "rstTemp.SortNum", "rstTemp!SortNum") Then MsgBox "???" ' If FindAndReplace(mdl, "Properties.", "Properties!") Then MsgBox "???" ' ' If FindAndReplace(mdl, "cDate", "currentDate") Then MsgBox "???" ' If FindAndReplace(mdl, "OpenQueryDef", "QueryDefs") Then MsgBox "???" ' ' End If 'Next i ' Set MyObj = Application.CurrentProject.AllForms For i = 0 To MyObj.Count - 1 ' If MyObj(i).Name <> "" Then rcsFormlist.MoveFirst rcsFormlist.FindFirst "Name='" & MyObj(i).Name & "'" If rcsFormlist.NoMatch Then rcsFormlist.AddNew rcsFormlist!Name = MyObj(i).Name rcsFormlist.Update DoCmd.OpenForm MyObj(i).Name, acDesign Set mdl = Forms(MyObj(i).Name).Module rcs.MoveFirst Do Until rcs.EOF If FindAndReplace(mdl, rcs!Name & ".", rcs!Name & "!") Then MsgBox "???" rcs.MoveNext Loop If FindAndReplace(mdl, "!AbsolutePosition", ".AbsolutePosition") Then MsgBox "???" If FindAndReplace(mdl, "!AddNew", ".AddNew") Then MsgBox "???" If FindAndReplace(mdl, "!BatchCollisionCount", ".BatchCollisionCount") Then MsgBox "???" If FindAndReplace(mdl, "!BatchCollisions", ".BatchCollisions") Then MsgBox "???" If FindAndReplace(mdl, "!BatchSize", ".BatchSize") Then MsgBox "???" If FindAndReplace(mdl, "!BOF", ".BOF") Then MsgBox "???" If FindAndReplace(mdl, "!Bookmark", ".Bookmark") Then MsgBox "???" If FindAndReplace(mdl, "!Bookmarkable", ".Bookmarkable") Then MsgBox "???" If FindAndReplace(mdl, "!CacheSize", ".CacheSize") Then MsgBox "???" If FindAndReplace(mdl, "!CacheStart", ".CacheStart") Then MsgBox "???" If FindAndReplace(mdl, "!Cancel", ".Cancel") Then MsgBox "???" If FindAndReplace(mdl, "!CancelUpdate", ".CancelUpdate") Then MsgBox "???" If FindAndReplace(mdl, "!Clone", ".Clone") Then MsgBox "???" If FindAndReplace(mdl, "!Close", ".Close") Then MsgBox "???" If FindAndReplace(mdl, "!Connection", ".Connection") Then MsgBox "???" If FindAndReplace(mdl, "!CopyQueryDef", ".CopyQueryDef") Then MsgBox "???" If FindAndReplace(mdl, "!DateCreated", ".DateCreated") Then MsgBox "???" If FindAndReplace(mdl, "!Delete", ".Delete") Then MsgBox "???" If FindAndReplace(mdl, "!Edit", ".Edit") Then MsgBox "???" If FindAndReplace(mdl, "!EditMode", ".EditMode") Then MsgBox "???" If FindAndReplace(mdl, "!EOF", ".EOF") Then MsgBox "???" If FindAndReplace(mdl, "!Fields", ".Fields") Then MsgBox "???" If FindAndReplace(mdl, "!FillCache", ".FillCache") Then MsgBox "???" '!!!!!!!!!!!! ' If FindAndReplace(mdl, "strFilter", "strstrFilter") Then MsgBox "???" '!!!!!!!!!!!!! If FindAndReplace(mdl, "!FindFirst", ".FindFirst") Then MsgBox "???" If FindAndReplace(mdl, "!FindLast", ".FindLast") Then MsgBox "???" If FindAndReplace(mdl, "!FindNext", ".FindNext") Then MsgBox "???" If FindAndReplace(mdl, "!FindPrevious", ".FindPrevious") Then MsgBox "???" If FindAndReplace(mdl, "!GetRows", ".GetRows") Then MsgBox "???" If FindAndReplace(mdl, "!Index", ".Index") Then MsgBox "???" If FindAndReplace(mdl, "!LastModified", ".LastModified") Then MsgBox "???" If FindAndReplace(mdl, "!LastUpdated", ".LastUpdated") Then MsgBox "???" If FindAndReplace(mdl, "!LockEdits", ".LockEdits") Then MsgBox "???" If FindAndReplace(mdl, "!Move", ".Move") Then MsgBox "???" If FindAndReplace(mdl, "!MoveFirst", ".MoveFirst") Then MsgBox "???" If FindAndReplace(mdl, "!MoveLast", ".MoveLast") Then MsgBox "???" If FindAndReplace(mdl, "!MoveNext", ".MoveNext") Then MsgBox "???" If FindAndReplace(mdl, "!MovePrevious", ".MovePrevious") Then MsgBox "???" '!!!!!!!!!!!! ' Name '!!!!!!!!!!!! If FindAndReplace(mdl, "!NextRecordset", ".NextRecordset") Then MsgBox "???" If FindAndReplace(mdl, "!NoMatch", ".NoMatch") Then MsgBox "???" If FindAndReplace(mdl, "!OpenRecordset", ".OpenRecordset") Then MsgBox "???" If FindAndReplace(mdl, "!PercentPosition", ".PercentPosition") Then MsgBox "???" If FindAndReplace(mdl, "!Properties", ".Properties") Then MsgBox "???" If FindAndReplace(mdl, "!RecordCount", ".RecordCount") Then MsgBox "???" If FindAndReplace(mdl, "!RecordStatus", ".RecordStatus") Then MsgBox "???" If FindAndReplace(mdl, "!Requery", ".Requery") Then MsgBox "???" If FindAndReplace(mdl, "!Restartable", ".Restartable") Then MsgBox "???" If FindAndReplace(mdl, "!Seek", ".Seek") Then MsgBox "???" If FindAndReplace(mdl, "!Sort", ".Sort") Then MsgBox "???" If FindAndReplace(mdl, "!StillExecuting", ".StillExecuting") Then MsgBox "???" If FindAndReplace(mdl, "!Transactions", ".Transactions") Then MsgBox "???" If FindAndReplace(mdl, "!Type", ".Type") Then MsgBox "???" If FindAndReplace(mdl, "!Updatable", ".Updatable") Then MsgBox "???" If FindAndReplace(mdl, "!Update", ".Update") Then MsgBox "???" If FindAndReplace(mdl, "!UpdateOptions", ".UpdateOptions") Then MsgBox "???" If FindAndReplace(mdl, "!ValidationRule", ".ValidationRule") Then MsgBox "???" If FindAndReplace(mdl, "!ValidationText", ".ValidationText") Then MsgBox "???" '!!!!!!!!!!!!! ' If FindAndReplace(mdl, "!Zvalue", ".Zvalue") Then MsgBox "???" ' If FindAndReplace(mdl, "!GNA_Name", ".GNA_Name") Then MsgBox "???" ' If FindAndReplace(mdl, "!GNA_FlU", ".GNA_FlU") Then MsgBox "???" ' If FindAndReplace(mdl, "!GNA_List", ".GNA_List") Then MsgBox "???" ' If FindAndReplace(mdl, "!Zformat", ".Zformat") Then MsgBox "???" If FindAndReplace(mdl, "Формы", "Forms") Then MsgBox "???" If FindAndReplace(mdl, "Форма", "Form") Then MsgBox "???" If FindAndReplace(mdl, "Столбец", "Column") Then MsgBox "???" 'If FindAndReplace(mdl, "rstTemp.SortNum", "rstTemp!SortNum") Then MsgBox "???" If FindAndReplace(mdl, "Properties.", "Properties!") Then MsgBox "???" If FindAndReplace(mdl, "cDate", "currentDate") Then MsgBox "???" If FindAndReplace(mdl, "CurCalcurrentDate", "CurCalcDate") Then MsgBox "???" If FindAndReplace(mdl, "OpenQueryDef", "QueryDefs") Then MsgBox "???" 'замена Формы->Forms в источниках форм и контролов If ReplaceFormControlsRowSourse(Forms(MyObj(i).Name)) <> 0 Then DoCmd.Beep DoCmd.Close acForm, MyObj(i).Name, acSaveYes End If Next i ' 'Set MyObj = Application.CurrentProject.AllReports ' 'For i = 0 To MyObj.Count - 1 ' DoCmd.OpenReport MyObj(i).Name, acDesign ' Set mdl = Reports(MyObj(i).Name).Module ' rcs.MoveFirst ' Do Until rcs.EOF ' If FindAndReplace(mdl, rcs!Name & ".", rcs!Name & "!") Then MsgBox "???" ' rcs.MoveNext ' Loop ' If FindAndReplace(mdl, "!AbsolutePosition", ".AbsolutePosition") Then MsgBox "???" ' If FindAndReplace(mdl, "!AddNew", ".AddNew") Then MsgBox "???" ' If FindAndReplace(mdl, "!BatchCollisionCount", ".BatchCollisionCount") Then MsgBox "???" ' If FindAndReplace(mdl, "!BatchCollisions", ".BatchCollisions") Then MsgBox "???" ' If FindAndReplace(mdl, "!BatchSize", ".BatchSize") Then MsgBox "???" ' If FindAndReplace(mdl, "!BOF", ".BOF") Then MsgBox "???" ' If FindAndReplace(mdl, "!Bookmark", ".Bookmark") Then MsgBox "???" ' If FindAndReplace(mdl, "!Bookmarkable", ".Bookmarkable") Then MsgBox "???" ' If FindAndReplace(mdl, "!CacheSize", ".CacheSize") Then MsgBox "???" ' If FindAndReplace(mdl, "!CacheStart", ".CacheStart") Then MsgBox "???" ' If FindAndReplace(mdl, "!Cancel", ".Cancel") Then MsgBox "???" ' If FindAndReplace(mdl, "!CancelUpdate", ".CancelUpdate") Then MsgBox "???" ' If FindAndReplace(mdl, "!Clone", ".Clone") Then MsgBox "???" ' If FindAndReplace(mdl, "!Close", ".Close") Then MsgBox "???" ' If FindAndReplace(mdl, "!Connection", ".Connection") Then MsgBox "???" ' If FindAndReplace(mdl, "!CopyQueryDef", ".CopyQueryDef") Then MsgBox "???" ' If FindAndReplace(mdl, "!DateCreated", ".DateCreated") Then MsgBox "???" ' If FindAndReplace(mdl, "!Delete", ".Delete") Then MsgBox "???" ' ' If FindAndReplace(mdl, "!Edit", ".Edit") Then MsgBox "???" ' If FindAndReplace(mdl, "!EditMode", ".EditMode") Then MsgBox "???" ' If FindAndReplace(mdl, "!EOF", ".EOF") Then MsgBox "???" ' If FindAndReplace(mdl, "!Fields", ".Fields") Then MsgBox "???" ' If FindAndReplace(mdl, "!FillCache", ".FillCache") Then MsgBox "???" ' '!!!!!!!!!!!! ' ' If FindAndReplace(mdl, "strFilter", "strstrFilter") Then MsgBox "???" ' '!!!!!!!!!!!!! ' If FindAndReplace(mdl, "!FindFirst", ".FindFirst") Then MsgBox "???" ' If FindAndReplace(mdl, "!FindLast", ".FindLast") Then MsgBox "???" ' If FindAndReplace(mdl, "!FindNext", ".FindNext") Then MsgBox "???" ' If FindAndReplace(mdl, "!FindPrevious", ".FindPrevious") Then MsgBox "???" ' ' If FindAndReplace(mdl, "!GetRows", ".GetRows") Then MsgBox "???" ' If FindAndReplace(mdl, "!Index", ".Index") Then MsgBox "???" ' If FindAndReplace(mdl, "!LastModified", ".LastModified") Then MsgBox "???" ' If FindAndReplace(mdl, "!LastUpdated", ".LastUpdated") Then MsgBox "???" ' If FindAndReplace(mdl, "!LockEdits", ".LockEdits") Then MsgBox "???" ' If FindAndReplace(mdl, "!Move", ".Move") Then MsgBox "???" ' If FindAndReplace(mdl, "!MoveFirst", ".MoveFirst") Then MsgBox "???" ' If FindAndReplace(mdl, "!MoveLast", ".MoveLast") Then MsgBox "???" ' If FindAndReplace(mdl, "!MoveNext", ".MoveNext") Then MsgBox "???" ' If FindAndReplace(mdl, "!MovePrevious", ".MovePrevious") Then MsgBox "???" ' '!!!!!!!!!!!! '' Name ' '!!!!!!!!!!!! ' ' If FindAndReplace(mdl, "!NextRecordset", ".NextRecordset") Then MsgBox "???" ' If FindAndReplace(mdl, "!NoMatch", ".NoMatch") Then MsgBox "???" ' If FindAndReplace(mdl, "!OpenRecordset", ".OpenRecordset") Then MsgBox "???" ' If FindAndReplace(mdl, "!PercentPosition", ".PercentPosition") Then MsgBox "???" ' If FindAndReplace(mdl, "!Properties", ".Properties") Then MsgBox "???" ' If FindAndReplace(mdl, "!RecordCount", ".RecordCount") Then MsgBox "???" ' If FindAndReplace(mdl, "!RecordStatus", ".RecordStatus") Then MsgBox "???" ' If FindAndReplace(mdl, "!Requery", ".Requery") Then MsgBox "???" ' If FindAndReplace(mdl, "!Restartable", ".Restartable") Then MsgBox "???" ' If FindAndReplace(mdl, "!Seek", ".Seek") Then MsgBox "???" ' If FindAndReplace(mdl, "!Sort", ".Sort") Then MsgBox "???" ' If FindAndReplace(mdl, "!StillExecuting", ".StillExecuting") Then MsgBox "???" ' If FindAndReplace(mdl, "!Transactions", ".Transactions") Then MsgBox "???" ' If FindAndReplace(mdl, "!Type", ".Type") Then MsgBox "???" ' If FindAndReplace(mdl, "!Updatable", ".Updatable") Then MsgBox "???" ' If FindAndReplace(mdl, "!Update", ".Update") Then MsgBox "???" ' If FindAndReplace(mdl, "!UpdateOptions", ".UpdateOptions") Then MsgBox "???" ' If FindAndReplace(mdl, "!ValidationRule", ".ValidationRule") Then MsgBox "???" ' If FindAndReplace(mdl, "!ValidationText", ".ValidationText") Then MsgBox "???" ' ' '!!!!!!!!!!!!! '' If FindAndReplace(mdl, "!Zvalue", ".Zvalue") Then MsgBox "???" '' If FindAndReplace(mdl, "!GNA_Name", ".GNA_Name") Then MsgBox "???" '' If FindAndReplace(mdl, "!GNA_FlU", ".GNA_FlU") Then MsgBox "???" '' If FindAndReplace(mdl, "!GNA_List", ".GNA_List") Then MsgBox "???" '' If FindAndReplace(mdl, "!Zformat", ".Zformat") Then MsgBox "???" ' If FindAndReplace(mdl, "Формы", "Forms") Then MsgBox "???" '' If FindAndReplace(mdl, "rstTemp.SortNum", "rstTemp!SortNum") Then MsgBox "???" ' If FindAndReplace(mdl, "Properties.", "Properties!") Then MsgBox "???" ' '' If FindAndReplace(mdl, "cDate", "currentDate") Then MsgBox "???" ' If FindAndReplace(mdl, "OpenQueryDef", "QueryDefs") Then MsgBox "???" ' ' If ReplaceFormControlsRowSourse(Forms(MyObj(i).Name)) <> 0 Then ' 'MsgBox MyObj(i).Name ' End If ' ' DoCmd.Close acReport, MyObj(i).Name, acSaveYes 'Next i rcsFormlist.Close Application.Echo True End Function Function FindAndReplaceIsNull(mdl As Module, strSearchText As String) As Boolean Dim lngSLine As Long, lngSCol As Long Dim lngELine As Long, lngECol As Long Dim strLine As String, strNewLine As String Dim intChr As Integer, intBefore As Integer, _ intAfter As Integer Dim strLeft As String, strRight As String Dim strArg As String Dim BegArg As Integer, EndArg As Integer, iSKC As Long Dim strKVC As String Dim BegArg1 As Integer, EndArg1 As Integer strKVC = """" + """" ' Open module. 'DoCmd.OpenModule strModuleName ' Return reference to Module object. 'Set mdl = Modules(strModuleName) lngSLine = 0 lngSCol = 0 lngELine = 0 lngECol = 0 ' Search for string. Do While mdl.Find(strSearchText, lngSLine, lngSCol, lngELine, lngECol) ' Store text of line containing string. strLine = mdl.Lines(lngSLine, Abs(lngELine - lngSLine) + 1) ' Determine length of line. intChr = Len(strLine) ' Determine number of characters preceding search text. intBefore = lngSCol - 1 ' Determine number of characters following search text. intAfter = intChr - CInt(lngECol - 1) ' Store characters to left of search text. strLeft = Left$(strLine, intBefore) ' Store characters to right of search text. strRight = Right$(strLine, intAfter) BegArg = InStr(strRight, "(") EndArg = InStr(strRight, ")") iSKC = 0 Do While InStr(Mid(strRight, BegArg + 1, EndArg - BegArg - 1), "(") <> 0 BegArg1 = InStr(Mid(strRight, BegArg + 1, EndArg - BegArg - 1), "(") Do iSKC = iSKC + 1 BegArg1 = InStr(BegArg1 + 1, Mid(strRight, BegArg + 1, EndArg - BegArg - 1), "(") Loop While BegArg1 <> 0 BegArg = EndArg EndArg = InStr(EndArg + 1, strRight, ")") Loop BegArg = InStr(strRight, "(") EndArg = InStr(strRight, ")") Do Until iSKC = 0 EndArg = InStr(EndArg + 1, strRight, ")") iSKC = iSKC - 1 Loop strArg = Mid(strRight, BegArg + 1, EndArg - BegArg - 1) strRight = Mid(strRight, EndArg + 1) ' Construct string with replacement text. strNewLine = strLeft & "Nz(" & strArg & "," & strKVC & ")=" & strKVC & strRight ' Replace original line. mdl.ReplaceLine lngSLine, strNewLine 'FindAndReplace = True lngSCol = lngSCol + 1 lngELine = 0 lngECol = 0 Loop ' Else ' MsgBox "Text not found." ' FindAndReplace = False ' End If Exit_FindAndReplaceIsNull: Exit Function Error_FindAndReplaceIsNull: MsgBox Err & ": " & Err.Description FindAndReplaceIsNull = False Resume Exit_FindAndReplaceIsNull End Function Function ReplaceFromModulesIsNull() As Integer Dim i As Integer Dim MyObj As Object Dim mdl As Module Dim rcs As Recordset Dim FStr As String Set MyObj = Application.CurrentProject.AllModules 'Set rcs = CurrentDb().OpenRecordset("rcslist") FStr = "IsNull" For i = 0 To MyObj.Count - 1 If MyObj(i).Name <> "ИзменениеМодулей" Then DoCmd.OpenModule MyObj(i).Name Set mdl = Modules(MyObj(i).Name) If FindAndReplaceIsNull(mdl, FStr) Then MsgBox "???" End If Next i Set MyObj = Application.CurrentProject.AllForms For i = 0 To MyObj.Count - 1 'If MyObj(i).Name = "Лицевые счета" Then DoCmd.OpenForm MyObj(i).Name, acDesign Set mdl = Forms(MyObj(i).Name).Module If FindAndReplaceIsNull(mdl, FStr) Then MsgBox "???" DoCmd.Close acForm, MyObj(i).Name, acSaveYes ' End If Next i Set MyObj = Application.CurrentProject.AllReports For i = 0 To MyObj.Count - 1 DoCmd.OpenReport MyObj(i).Name, acDesign Set mdl = Reports(MyObj(i).Name).Module If FindAndReplaceIsNull(mdl, FStr) Then MsgBox "???" DoCmd.Close acReport, MyObj(i).Name, acSaveYes Next i End Function Function ReplaceFromQuery() As Integer Dim i As Integer, j As Integer Dim MyObj As Object, qrd As QueryDef Dim sSQL As String Dim lngSLine As Long, lngSCol As Long, cnt As Integer 'Dim rcs As Recordset Set MyObj = CurrentDb().QueryDefs cnt = 0 For i = 0 To MyObj.Count - 1 Set qrd = MyObj(i) ' If InStr(qrd.SQL, "Forms") > 0 Then lngSCol = InStr(1, qrd.SQL, "Forms") Do While lngSCol > 0 qrd.SQL = Left(qrd.SQL, lngSCol - 1) + "Forms" + Right(qrd.SQL, Len(qrd.SQL) - lngSCol - 4) 'qrd.SQL = sSQL cnt = cnt + 1 lngSCol = InStr(lngSCol, qrd.SQL, "Forms") Loop ' End If 'qrd.SQL = sSQL Next i ReplaceFromQuery = cnt End Function Function RFC() As Boolean Dim MyObj As Object Dim i As Integer Set MyObj = Application.CurrentProject.AllForms For i = 0 To MyObj.Count - 1 DoCmd.OpenForm MyObj(i).Name, acDesign If ReplaceFormControlsRowSourse(Forms(MyObj(i).Name)) <> 0 Then MsgBox MyObj(i).Name DoCmd.Close acForm, MyObj(i).Name, acSaveYes Next i RFC = True End Function Function ReplaceFormControlsRowSourse(frm As Form) As Integer Dim i As Integer, j As Integer, cnt As Integer Dim lngSLine As Long, lngSCol As Long 'Dim MyObj As Object 'Dim frm As Form Dim str As String 'Dim rcs As Recordset 'Set MyObj = Application.CurrentProject.AllForms cnt = 0 'application.echo false 'For i = 0 To MyObj.Count - 1 ' DoCmd.OpenForm MyObj(i).Name, acDesign ' Set frm = Forms(MyObj(i).Name) lngSCol = InStr(1, frm.RecordSource, "Формы") Do While lngSCol > 0 frm.RecordSource = Left(frm.RecordSource, lngSCol - 1) + "Forms" + Right(frm.RecordSource, Len(frm.RecordSource) - lngSCol - 4) cnt = cnt + 1 lngSCol = InStr(lngSCol, frm.RecordSource, "Формы") Loop For j = 0 To frm.Count - 1 ' If InStr(frm.RecordSource, "[Forms]!") > 0 Then ' cnt = cnt + 1 ' End If ' On Error Resume Next If frm(j).ControlType = acComboBox Or frm(j).ControlType = acListBox Then lngSCol = InStr(1, frm(j).RowSource, "Формы") Do While lngSCol > 0 frm(j).RowSource = Left(frm(j).RowSource, lngSCol - 1) + "Forms" + Right(frm(j).RowSource, Len(frm(j).RowSource) - lngSCol - 4) cnt = cnt + 1 lngSCol = InStr(lngSCol, frm(j).RowSource, "Формы") Loop End If ' On Error GoTo 0 Next j ' DoCmd.Close acForm, MyObj(i).Name, acSaveYes 'Next i ReplaceFormControlsRowSourse = cnt End Function Function ReplaceReportControlsRowSourse() As Integer Dim i As Integer, j As Integer, cnt As Integer Dim lngSLine As Long, lngSCol As Long Dim MyObj As Object Dim frm As Report Dim str As String 'Dim rcs As Recordset Set MyObj = Application.CurrentProject.AllReports cnt = 0 'application.echo false For i = 0 To MyObj.Count - 1 DoCmd.OpenReport MyObj(i).Name, acDesign Set frm = Reports(MyObj(i).Name) lngSCol = InStr(1, frm.RecordSource, "Формы") Do While lngSCol > 0 frm.RecordSource = Left(frm.RecordSource, lngSCol - 1) + "Forms" + Right(frm.RecordSource, Len(frm.RecordSource) - lngSCol - 4) cnt = cnt + 1 lngSCol = InStr(lngSCol, frm.RecordSource, "Формы") Loop For j = 0 To frm.Count - 1 ' If InStr(frm.RecordSource, "[Forms]!") > 0 Then ' cnt = cnt + 1 ' End If ' On Error Resume Next If frm(j).ControlType = acComboBox Or frm(j).ControlType = acListBox Then lngSCol = InStr(1, frm(j).RowSource, "Формы") Do While lngSCol > 0 frm(j).RowSource = Left(frm(j).RowSource, lngSCol - 1) + "Forms" + Right(frm(j).RowSource, Len(frm(j).RowSource) - lngSCol - 4) cnt = cnt + 1 lngSCol = InStr(lngSCol, frm(j).RowSource, "Формы") Loop End If ' On Error GoTo 0 Next j DoCmd.Close acReport, MyObj(i).Name, acSaveYes Next i ReplaceReportControlsRowSourse = cnt End Function если код небольшой можно обойтись редактором (найти->заменить) ... |
|||
:
Нравится:
Не нравится:
|
|||
23.03.2004, 11:14 |
|
|
start [/forum/topic.php?fid=45&gotonew=1&tid=1675872]: |
0ms |
get settings: |
10ms |
get forum list: |
13ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
27ms |
get topic data: |
12ms |
get first new msg: |
7ms |
get forum data: |
3ms |
get page messages: |
60ms |
get tp. blocked users: |
2ms |
others: | 97ms |
total: | 237ms |
0 / 0 |