LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default If .,AND ... Then failure

Pete,

First check and make sure you have spaces where they need to be
If FSSN = rs.Fields("SSN") AND FDate = rs.("Date")AND _
FFrom = rs.("From")Then
s/b
If FSSN = rs.Fields("SSN") AND FDate = rs.("Date") AND _
FFrom = rs.("From") Then

Next you'll need to verify that the date doesn't have minutes/seconds in
order to get an exact match (you can check this by formatting as a number
with decimals - you don't want decimals); and make sure that you get an
exact match on the "From".

To double check - you might want to break up your if's and test...
If FSSN = rs.Fields("SSN") then
MsgBox "SSN match"
If FDate = rs.("Date") then
MsgBox "Date match"
If FFrom = rs.("From") then
MsgBox "From match"
--
sb
"Pete T" wrote in message
om...
I have a Spreadsheet for Staff to record their Voice Messages &
Followups. They use UserForms to input the initial data, which could
be from either of two sources Employers or Claimant. Once they have
the record on the spreadsheet they can update that record, with
additional data and then Update that record to a Database(elsewhere).

My problem now is if they get a call from the employer and post the
record, which uses the Claimants SSN as the search criteria to Update
the Recod on the Database; THEN a Claimant calls in and we attempt to
create a new record. Since the SSN are the same the database attempts
to update the original record instead of adding a destict record (one
for the Employer and one for the Claimant).

Here is a protion of the Code:

LG = Range("F" & 1).Value
Qry = "LOG" & LG ' sets the Query

R = ActiveCell.Row "This row has the data to be Added or Updated

FDate = Range("C" & R).Value ' Initial Date of Call
FSSN = Range("F" & R).Value ' The Claimants SSN
FFrom = Range("E" & R).Value ' Call from one of two (Employer or
Claimant)
adjlog = "\\fld035728\Team\AdjLog.mdb"
Set dbs = OpenDatabase(adjlog)
Set qd = dbs.CreateQueryDef(Qry)
qd.SQL = "SELECT * FROM TEntry " _
& "WHERE Login='" & LG & "';"
Set rs = dbs.OpenRecordset(Qry)

notfound = False
rs.MoveFirst
Do
If FSSN = rs.Fields("SSN") Then
notfound = True
rs.Edit
rs.Fields("Complete") = Range("A" & R).Value
rs.Fields("Login") = Range("F" & 1).Value
rs.Fields("From") = Range("E" & R).Value
rs.Fields("Date") = Range("C" & R).Value
rs.Fields("Time") = Range("D" & R).Value
rs.Fields("SSN") = Range("F" & R).Value
...... etc.
Note: if the record is not found then it moves the rs. Add function,
etc.

I want the If statment to be like:
If FSSN = rs.Fields("SSN") AND FDate = rs.("Date")AND _
FFrom = rs.("From")Then

But, this fails. and it ADDs a new record everytime. The If statement
with one item works as is listed above in the code, but I need to add
items to narrow the search? Thanks



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
password failure jmurphy Excel Worksheet Functions 0 January 20th 09 07:08 AM
vlookup failure & ctrl-f failure? joemeshuggah Excel Discussion (Misc queries) 4 December 22nd 08 07:22 PM
failure of web query Dr Alok Modi MD Excel Discussion (Misc queries) 0 February 21st 08 12:06 PM
sumproduct failure? Herman56 Excel Discussion (Misc queries) 4 March 30th 06 04:21 PM
Catastrophic failure HELP!! Christy[_2_] Excel Programming 1 September 29th 03 01:40 AM


All times are GMT +1. The time now is 02:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"