database problem

blinx
10-19-2004, 09:25 PM
Hi I/m using this code:

do until rslog.eof
rslog.AddNew
rslog!branch = Left(filename, 3)
If UCase(Mid(filename, 4, 2)) = UCase(salesfile2) Then
rslog!A = "1"
rslog!Date = Mid(filename, 6, 3)
ElseIf UCase(Mid(filename, 4, 2)) = UCase(salesfile3) Then
rslog!B = "1"
end if
loop
to open recordset(rslog) and add new data to it
The problem is how to check the data so if the data has the same branch, then it would updating the data in the same row
E.g:

Branch Date A B
AAA 20 1 1

because right now, my code produce 2 line like this:
AAA 20 1
AAA 20 1

Please give me real code to solve this
Thx

Iceman Solope
10-20-2004, 12:30 PM
could you plz use VB brackets before and after ur code, this could help more to understand ur problem

after --> [/VB]
before --> [VB]


Hi I/m using this code:

do until rslog.eof
rslog.AddNew
rslog!branch = Left(filename, 3)
If UCase(Mid(filename, 4, 2)) = UCase(salesfile2) Then
rslog!A = "1"
rslog!Date = Mid(filename, 6, 3)
ElseIf UCase(Mid(filename, 4, 2)) = UCase(salesfile3) Then
rslog!B = "1"
end if
loop
to open recordset(rslog) and add new data to it
The problem is how to check the data so if the data has the same branch, then it would updating the data in the same row
E.g:

Branch Date A B
AAA 20 1 1

because right now, my code produce 2 line like this:
AAA 20 1
AAA 20 1

Please give me real code to solve this
Thx

MKoslof
10-20-2004, 06:58 PM
In order to commit your .addnew method, you need to add the .update method to save your changes.

And in order to check if the values already exist, run a query against your condition. Do a SELECT query with a WHERE clause that checks for any records that match. If the recordcount is greater zero, or if you check for EOF and at least one record is returned, you know it exists.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum