Re: Searching And Checking Rules Depenging On Rule

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



SEAN DI''''ANNO wrote:

ok.really trying hard and it has taken me all day to come up with

 Dim MyDB As Database
    Dim MyRecSet As Recordset

Point of style: I'm not happy with this name. Could you come up with something more suggestive, such as UsersFaultSpecifications? You read at least two Recordsets and you probably write one, so I think their names should convey a sense of what each one's purpose is.


    Dim SQLString As String
    Dim Criteria As String
    Set MyDB = CurrentDb()
    Set MyRecSet = MyDB.OpenRecordset("FaultItems", dbOpenDynaset)

You don't need Dynaset; Snapshot should suffice, since you're only going to look at them, not change them. However, you might want to store your scores in the Table of data that you're testing using these criteria, so that recordset might need to be a Dynaset, if you want to store the results there.


Criteria = "FieldName like " & "'" & fldField.Name & "'" MyRecSet.FindFirst Criteria Do Until MyRecSet.NoMatch
MyRecSet.FindNext Criteria
Loop


Am I on the right lines? if the field name is found then do some function depnding on the rule and value of fldfield.value?

Something like this. There are probably various ways to proceed, but I'd choose a record in the Table containing the data, then loop through the list of criteria. For each criterion, fetch the value specified field in the data record (but with care; some may be text strings, others may be numbers) and apply the specified criterion to that value. You'll have to decide how to do that, and you may need to do some error checking on the criteria themselves to be sure that they are expressed clearly. This should be a fun challenge. I suggest you start simply, perhaps by specifying strings that would make sense in a "Like ...." clause, or maybe even by restricting the choices to exact matches until you have your system debugged.


Anyway, having gone through all the criteria for that record, I'd assign a score to it, then repeat all this with the next record.

You can do a couple of things with the score that you compute: store it into a field in the Table of data, store it (with a copy of the primary key value) into a separate Table of scores, or return it as a value of your function. In this last case, your function could store the values into an array to be returned when you've read all the records, or you could return just one value for each function call (but then the calling program would probably need to open the recordset of user data, call the function once for each record, and close the recordset).

  -- Vincent Johns <vjohns@xxxxxxxxxxxxxxxxxx>
  Please feel free to quote anything I say here.

.



Relevant Pages

  • Re: Record Lookup
    ... Dim SelectedRows() As DataRow ... The select method returns all rows matching the criteria. ... primary key in the table to the field that I wanted to use for the search ... Dim drSelectedRecord As DataRow ...
    (microsoft.public.dotnet.languages.vb)
  • =?windows-1252?Q?Re=3A_Dlookup=85DoCmd=2EOpenForm=2E=2Eor=3F?=
    ... SQL and looks for the recordset matching the criteria in the "search" ... Dim rs As DAO.Recordset ... Dim strDialog As String ... MsgBox "Missing Date, Shift, or Area! ...
    (microsoft.public.access.formscoding)
  • Re: Conditional Copy/Paste
    ... Dim ws As Worksheet ... 'Add the heading to the criteria area ... 'transfer data to individual City worksheets ... Set cityListRange = Sheets.Range.CurrentRegion ...
    (microsoft.public.excel.misc)
  • Re: Delete a row with a certain phrase?
    ... Dim rTable As Range ... 'Get the criteria in the form of text or number. ... If vCriteria = "False" Then Exit Sub ... If lCol = 0 Then Exit Sub ...
    (microsoft.public.excel.programming)
  • Re: Adv Filter fails in macro, works manually
    ... 'first row of criteria ... Dim rgCriteria As Range ... Dim iRow, iCol As Integer ...
    (microsoft.public.excel.programming)