Re: ADO Find Help?



The difference is when you do an add new, there are no other records that
meet the filter, so only one record gets updated. You need some other unique
record identifier to locate the exact row you want to update (via the .Find
method), then update the value in the recordset (I'm not familiar with what
the '!' syntax does). Once the single record is found, you should be able to
update that row in the recordset (rs("ColumnName") = valueX) and issue the
..Update and it only updates that single record...

Hope this helps.
<greg4168@xxxxxxxxx> wrote in message
news:1126186002.856192.70570@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Hi, I'm new to ADO and am hoping somebody here can steer me in the
> right direction.
>
> I'm using VB6, and an SQL database. I simply want to search the
> database for a record containing two key values. For example, I want
> to find a record where column A = xx, and column B = yy. I'm using
> .Filter to do this, and believe I have it correct. Here's my filter
> statement: .Filter = ("dbcolA = '" & valueA & "' and dbcolB = '" &
> valueB & "'"). The result of this statement comes out to "dbcolA =
> 'valueA' and dbcolB = 'valueB'"
>
> The next part I'm doing is either adding a new record to the table, or
> updating the existing record, based on the result of the filter. The
> way I'm doing this is as so:
> If .EOF Then
> .AddNew
> End If
> !dbcolA = valueA
> !dbcolB = valueB
> .Update
> .Close
> .Filter = adFilterNone
>
> So, the only difference between a new record and an updated record is
> the .AddNew statement.
>
> The result of this is that when valueB changes, a new record is added
> to the table as expected, but the valueB is propogated across all
> records that contain valueA. I want it to create a new record, but not
> touch any of the existing records.
>
> What am I doing wrong??
>
> Thanks very much...
>


.



Relevant Pages

  • Re: Sorting data to last 30 days
    ... I think you should explore applying the filter to the SQL database so that ... There are problems with trying to use AutoFilter here: custom criteria don't ... filter criteria. ...
    (microsoft.public.excel.misc)
  • ADO Find Help?
    ... I'm using VB6, and an SQL database. ... ..Filter to do this, and believe I have it correct. ... The result of this is that when valueB changes, ... records that contain valueA. ...
    (microsoft.public.data.ado)
  • Re: Database Filter question
    ... > I use ADO to connect to an SQL Database. ... I use an ADODataSet to hold a ... > When I set the Filtered property to True (ADODataset1.Filtered:= ... > will it automatically Execute its CommandText and then filter the new ...
    (borland.public.delphi.database.ado)
  • Database Filter question
    ... I use ADO to connect to an SQL Database. ... I use an ADODataSet to hold a ... complete recordset from a select query. ... automatically Execute its CommandText and then filter the new resultset? ...
    (borland.public.delphi.database.ado)
  • Re: Database Filter question
    ... > Allan Nielsen wrote: ... >> I use ADO to connect to an SQL Database. ... I use an ADODataSet to hold a ... >> will it automatically Execute its CommandText and then filter the new ...
    (borland.public.delphi.database.ado)