Новые сообщения [новые:0]
Дайджест
Горячие темы
Избранное [новые:0]
Форумы
Пользователи
Статистика
Статистика нагрузки
Мод. лог
Поиск
|
14.11.2006, 09:28
|
|||
---|---|---|---|
|
|||
клон Me.Recordset после фильтров |
|||
#18+
adp - проект на записи в форме в табличном виде наложили фильтр. нужно получить Recordset записей, которые после наложения фильтра видны на форме и пройтись по нему. как получитьт такой рекордсет? метод Clone вроде клонирует без учета фильтра. ... |
|||
:
Нравится:
Не нравится:
|
|||
|
14.11.2006, 10:35
|
|||
---|---|---|---|
клон Me.Recordset после фильтров |
|||
#18+
адп под рукой нет в мдб me.recordset содержит отфилтрованное ... |
|||
:
Нравится:
Не нравится:
|
|||
|
14.11.2006, 10:56
|
|||
---|---|---|---|
|
|||
клон Me.Recordset после фильтров |
|||
#18+
На Clone наложи аналогичный фильтр ... |
|||
:
Нравится:
Не нравится:
|
|||
|
14.11.2006, 11:15
|
|||
---|---|---|---|
|
|||
клон Me.Recordset после фильтров |
|||
#18+
baclanovНа Clone наложи аналогичный фильтрнакладываю, дальше прохожу по клонированному: Код: plaintext 1. 2. 3. 4. 5.
как пройти только через те, что были отфильтрованы? ... |
|||
:
Нравится:
Не нравится:
|
|||
|
14.11.2006, 12:13
|
|||
---|---|---|---|
|
|||
клон Me.Recordset после фильтров |
|||
#18+
Я использую функцию которая возвращает recordset (поля называюся Field0 и т.д., можно конечно переименовать и в начальные) обычно использую для подсчета суммы: Private Function CopyRS(ByRef mvarRsForm As ADODB.Recordset) As ADODB.Recordset Dim iField As Integer Dim iCountField As Integer Dim rsCurrent As ADODB.Recordset Dim rs As ADODB.Recordset Set rs = mvarRsForm.Clone rs.Filter = mvarRsForm.Filter rs.Sort = mvarRsForm.Sort With rs Set rsCurrent = New ADODB.Recordset iField = 0 iCountField = .Fields.Count - 1 For iField = 0 To iCountField If Not IsNull(.Fields(iField).DefinedSize) Then rsCurrent.Fields.Append "Field" & iField, .Fields(iField).Type, .Fields(iField).DefinedSize, .Fields(iField).Attributes Else rsCurrent.Fields.Append "Field" & iField, .Fields(iField).Type, , .Fields(iField).Attributes End If Next rsCurrent.CursorType = adOpenStatic rsCurrent.LockType = adLockOptimistic rsCurrent.Open If .EOF = False And .BOF = False Then .MoveFirst Do Until .EOF rsCurrent.AddNew For iField = 0 To iCountField If Len(.Fields(iField).Value) Then rsCurrent.Fields(iField).Value = .Fields(iField).Value End If Next rsCurrent.Update .MoveNext Loop Else .Close Set rs = Nothing Set CopyRS = rsCurrent Exit Function End If .Close End With Set rs = Nothing Set CopyRS = rsCurrent End Function ... |
|||
:
Нравится:
Не нравится:
|
|||
|
14.11.2006, 12:31
|
|||
---|---|---|---|
|
|||
клон Me.Recordset после фильтров |
|||
#18+
2 baclanov ну вот: MsgBox CopyRS(Me.sfrmSubForm.Form.Recordset).RecordCount что с фильтром, что без фильтра - у меня выдает одинаковое количество записей - все, что есть. я что-то не так делаю? ... |
|||
:
Нравится:
Не нравится:
|
|||
|
14.11.2006, 14:38
|
|||
---|---|---|---|
|
|||
клон Me.Recordset после фильтров |
|||
#18+
никто больше с такой задачей не сталкивался? ... |
|||
:
Нравится:
Не нравится:
|
|||
|
14.11.2006, 14:43
|
|||
---|---|---|---|
клон Me.Recordset после фильтров |
|||
#18+
copyrs - показать надо ... |
|||
:
Нравится:
Не нравится:
|
|||
|
14.11.2006, 14:46
|
|||
---|---|---|---|
|
|||
клон Me.Recordset после фильтров |
|||
#18+
ILL HEADcopyrs - показать надо в смысле? ... |
|||
:
Нравится:
Не нравится:
|
|||
|
14.11.2006, 14:49
|
|||
---|---|---|---|
|
|||
клон Me.Recordset после фильтров |
|||
#18+
Для подчинненой формы нужно взять значение свойства Form.Filter удалить из него название самой подчинненой формы и заменить кавычки апострафом. У меня работает. Код функции CopyRS приведен до строки "With rs" Private Sub cmdCountRecord_Click() Dim sFilter As String If Me.sfrmSubForm.Form.FilterOn Then sFilter = Me.sfrmSubForm.Form.Filter sFilter = Replace(sFilter, Me.sfrmSubForm.name & ".", "", 1, -1) sFilter = Replace(sFilter, Chr(34), "'", 1, -1) End If MsgBox CopyRS(Me.sfrmSubForm.Form.Recordset, sFilter).RecordCount End Sub Public Function CopyRS(ByRef mvarRsForm As ADODB.Recordset, ByRef sFilter As String) As ADODB.Recordset Dim iField As Integer Dim iCountField As Integer Dim rsCurrent As ADODB.Recordset Dim rs As ADODB.Recordset Set rs = mvarRsForm.Clone rs.Filter = sFilter ... |
|||
:
Нравится:
Не нравится:
|
|||
|
14.11.2006, 14:53
|
|||
---|---|---|---|
|
|||
клон Me.Recordset после фильтров |
|||
#18+
baclanovДля подчинненой формы нужно взять значение свойства Form.Filter удалить из него название самой подчинненой формы и заменить кавычки апострафом. У меня работает. Код функции CopyRS приведен до строки "With rs" Private Sub cmdCountRecord_Click() Dim sFilter As String If Me.sfrmSubForm.Form.FilterOn Then sFilter = Me.sfrmSubForm.Form.Filter sFilter = Replace(sFilter, Me.sfrmSubForm.name & ".", "", 1, -1) sFilter = Replace(sFilter, Chr(34), "'", 1, -1) End If MsgBox CopyRS(Me.sfrmSubForm.Form.Recordset, sFilter).RecordCount End Sub Public Function CopyRS(ByRef mvarRsForm As ADODB.Recordset, ByRef sFilter As String) As ADODB.Recordset Dim iField As Integer Dim iCountField As Integer Dim rsCurrent As ADODB.Recordset Dim rs As ADODB.Recordset Set rs = mvarRsForm.Clone rs.Filter = sFilter вы смотрели на текстовом поле? а на datetime? на числовом? ... |
|||
:
Нравится:
Не нравится:
|
|||
|
14.11.2006, 15:04
|
|||
---|---|---|---|
|
|||
клон Me.Recordset после фильтров |
|||
#18+
вопр.вы смотрели на текстовом поле? а на datetime? на числовом? С датой и целым проходит - проверил. С money нужно заменить запятую на точку, но не проверял ... |
|||
:
Нравится:
Не нравится:
|
|||
|
14.11.2006, 15:08
|
|||
---|---|---|---|
клон Me.Recordset после фильтров |
|||
#18+
возможно я чтото недопонял но вы входной рекордсет транслируете (в том числе со свойствами - фильтр, сорт) в выходной что вы хотите в результате ? ... |
|||
:
Нравится:
Не нравится:
|
|||
|
14.11.2006, 15:28
|
|||
---|---|---|---|
|
|||
клон Me.Recordset после фильтров |
|||
#18+
вопр.adp - проект на записи в форме в табличном виде наложили фильтр. нужно получить Recordset записей, которые после наложения фильтра видны на форме и пройтись по нему. как получитьт такой рекордсет? метод Clone вроде клонирует без учета фильтра. Получаем рекорсет отфильтрованных записей, можно с ним, например, вычисления делать: в adp формулы глючно работают, обычно только сложение нормально проходит. ... |
|||
:
Нравится:
Не нравится:
|
|||
|
14.11.2006, 16:16
|
|||
---|---|---|---|
|
|||
клон Me.Recordset после фильтров |
|||
#18+
baclanovС датой и целым проходит - проверил. С money нужно заменить запятую на точку, но не проверял на таких фильтрах не проходит: ((NAME ALike "%ист%")) ... |
|||
:
Нравится:
Не нравится:
|
|||
|
14.11.2006, 16:36
|
|||
---|---|---|---|
|
|||
клон Me.Recordset после фильтров |
|||
#18+
впр. на таких фильтрах не проходит: ((NAME ALike "%ист%")) Буква A не лишняя? и кавычки одинарные ... |
|||
:
Нравится:
Не нравится:
|
|||
|
14.11.2006, 16:37
|
|||
---|---|---|---|
|
|||
клон Me.Recordset после фильтров |
|||
#18+
baclanov вопр.вы смотрели на текстовом поле? а на datetime? на числовом? С датой и целым проходит - проверил. С money нужно заменить запятую на точку, но не проверял для текстовых полей вида: ля-ля-ля "текст в кавычках" ля-ля дает неправильный результат. ... |
|||
:
Нравится:
Не нравится:
|
|||
|
14.11.2006, 16:40
|
|||
---|---|---|---|
|
|||
клон Me.Recordset после фильтров |
|||
#18+
baclanov впр. на таких фильтрах не проходит: ((NAME ALike "%ист%")) Буква A не лишняя? и кавычки одинарные выделите на текстовом поле часть текста и сделайте "фильтр по выделенному". если выделили ист, то Form.Filter = ((NAME ALike "%ист%")) ... |
|||
:
Нравится:
Не нравится:
|
|||
|
14.11.2006, 16:42
|
|||
---|---|---|---|
|
|||
клон Me.Recordset после фильтров |
|||
#18+
Привожу справку по ADO: ADO API Reference Filter Property Indicates a filter for data in a Recordset. Settings and Return Values Sets or returns a Variant value, which can contain one of the following: Criteria string — a string made up of one or more individual clauses concatenated with AND or OR operators. Array of bookmarks — an array of unique bookmark values that point to records in the Recordset object. A FilterGroupEnum value. Remarks Use the Filter property to selectively screen out records in a Recordset object. The filtered Recordset becomes the current cursor. Other properties that return values based on the current cursor are affected, such as AbsolutePosition, AbsolutePage, RecordCount, and PageCount. This is because setting the Filter property to a specific value will move the current record to the first record that satisfies the new value. The criteria string is made up of clauses in the form FieldName-Operator-Value (for example, "LastName = 'Smith'"). You can create compound clauses by concatenating individual clauses with AND (for example, "LastName = 'Smith' AND FirstName = 'John'") or OR (for example, "LastName = 'Smith' OR LastName = 'Jones'"). Use the following guidelines for criteria strings: FieldName must be a valid field name from the Recordset. If the field name contains spaces, you must enclose the name in square brackets. Operator must be one of the following: <, >, <=, >=, <>, =, or LIKE. Value is the value with which you will compare the field values (for example, 'Smith', #8/24/95#, 12.345, or $50.00). Use single quotes with strings and pound signs (#) with dates. For numbers, you can use decimal points, dollar signs, and scientific notation. If Operator is LIKE, Value can use wildcards. Only the asterisk (*) and percent sign (%) wild cards are allowed, and they must be the last character in the string. Value cannot be null. Note To include single quotation marks (') in the filter Value, use two single quotation marks to represent one. For example, to filter on O'Malley, the criteria string should be "col1 = 'O''Malley'". To include single quotation marks at both the beginning and the end of the filter value, enclose the string with pound signs (#). For example, to filter on '1', the criteria string should be "col1 = #'1'#". There is no precedence between AND and OR. Clauses can be grouped within parentheses. However, you cannot group clauses joined by an OR and then join the group to another clause with an AND, like this: (LastName = 'Smith' OR LastName = 'Jones') AND FirstName = 'John' Instead, you would construct this filter as (LastName = 'Smith' AND FirstName = 'John') OR (LastName = 'Jones' AND FirstName = 'John') In a LIKE clause, you can use a wildcard at the beginning and end of the pattern (for example, LastName Like '*mit*'), or only at the end of the pattern (for example, LastName Like 'Smit*'). The filter constants make it easier to resolve individual record conflicts during batch update mode by allowing you to view, for example, only those records that were affected during the last UpdateBatch method call. Setting the Filter property itself may fail because of a conflict with the underlying data (for example, a record has already been deleted by another user). In such a case, the provider returns warnings to the Errors collection but does not halt program execution. A run-time error occurs only if there are conflicts on all the requested records. Use the Status property to locate records with conflicts. Setting the Filter property to a zero-length string ("") has the same effect as using the adFilterNone constant. Whenever the Filter property is set, the current record position moves to the first record in the filtered subset of records in the Recordset. Similarly, when the Filter property is cleared, the current record position moves to the first record in the Recordset. See the Bookmark property for an explanation of bookmark values from which you can build an array to use with the Filter property. Only Filters in the form of Criteria Strings (e.g. OrderDate > '12/31/1999') affect the contents of a persisted Recordset. Filters created with an Array of Bookmarks or using a value from the FilterGroupEnum will not affect the contents of the persisted Recordset. These rules apply to Recordsets created with either client-side or server-side cursors. ... |
|||
:
Нравится:
Не нравится:
|
|||
|
14.11.2006, 16:47
|
|||
---|---|---|---|
|
|||
клон Me.Recordset после фильтров |
|||
#18+
2 baclanov зачем мне справка? ваш код не работает, не мой. ... |
|||
:
Нравится:
Не нравится:
|
|||
|
14.11.2006, 16:49
|
|||
---|---|---|---|
|
|||
клон Me.Recordset после фильтров |
|||
#18+
Насколько я понимаю нужно писать целую функцию преобразующий фильтр Access к фильтру ADO ... |
|||
:
Нравится:
Не нравится:
|
|||
|
14.11.2006, 17:00
|
|||
---|---|---|---|
|
|||
клон Me.Recordset после фильтров |
|||
#18+
baclanovНасколько я понимаю нужно писать целую функцию преобразующий фильтр Access к фильтру ADOок, спасибо. можно попробовать. ... |
|||
:
Нравится:
Не нравится:
|
|||
|
14.11.2006, 17:26
|
|||
---|---|---|---|
|
|||
клон Me.Recordset после фильтров |
|||
#18+
sFilter = Me.sfrmSubForm.Form.Filter Вместо двух строчек: sFilter = Replace(sFilter, Me.sfrmSubForm.name & ".", "", 1, -1) sFilter = Replace(sFilter, Chr(34), "'", 1, -1) Напишите следующие: sFilter = Replace(sFilter, Chr(34) & Chr(34), "<myfindquote>", , , vbTextCompare) sFilter = Replace(sFilter , Chr(34), "'", , , vbTextCompare) sFilter = Replace(sFilter , "<myfindquote>", Chr(34), , , vbTextCompare) sFilter = Replace(sFilter , " ALike ", " Like ", , , vbTextCompare) sFilter = Replace(sFilter, Me.sfrmSubForm.Form.Name & ".", "", , , vbTextCompare) Удачи ... |
|||
:
Нравится:
Не нравится:
|
|||
|
13.03.2020, 14:05
|
|||
---|---|---|---|
|
|||
клон Me.Recordset после фильтров |
|||
#18+
Уважаемые форумчане, возникла проблема. Есть рекордсет, делаю фильтр по рекордсету, суммирую данные по одному из полей , далее хочу полученную сумму присвоить полю в первой строке в остальных строках поставить нули. Вопрос можно-ли сделать update в фильтре рекордсета. У меня на строчке update выходит ошибка Run-time error '-2147217865(80040e37) Invalin object name. Хотя имя источника запроса проходит, выполняет действия, затыкается когда я хочу поменять значение поля Вод кусочек кода Код: vbnet 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46.
... |
|||
:
Нравится:
Не нравится:
|
|||
|
|
start [/forum/topic.php?fid=45&mobile=1&tid=1610181]: |
0ms |
get settings: |
8ms |
get forum list: |
11ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
60ms |
get topic data: |
10ms |
get forum data: |
2ms |
get page messages: |
53ms |
get tp. blocked users: |
2ms |
others: | 9ms |
total: | 161ms |
0 / 0 |