Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How about using
If rs.Fields("Login")=Range("F"&1).Text And _ ColE = rs.Fields(SSN") Then the text property should return a text string instead of the actual number value Paul D "Pete T" wrote in message m... Merjet you are the Master... Thanks with some minor adjustment of my If..Then statement it work bueatifully. Now I need to complicate the If..Then with a double search as we will have multiple users and I need to narrow the search area. Each staff member who will be adding and updating records here has a unique login. The login resides at one location on the Spreadsheet (F1), If I attempt to use the following If..Then : If rs.Fields("Login")=Range("F"&1).Value And _ ColE = rs.Fields(SSN") Then It doesn't work, as the first login value is i.e. "6701" and the F1 Range is 6701 . without quotes. So everything fails to match and the code ends doing nothing? I have heard that there is a way to first create a temporary query sorting out all other Login's then run the If...Then on the SSN only, do you know how? Thanks Again, "merjet" wrote in message .net... Phobos' suggestion to add a primary key to the Access table would help, but looping the recordset is still needed. Try the following: Dim rs As Recordset Dim ColE As Variant Dim bFound As Boolean . . . . . For R = 4 To 300 ColE = Worksheets("Contacts").Cells(R, 5).Value If ColE = "" Then Exit For bFound = False rs.MoveFirst Do If Worksheets("Contacts").Cells(R, 5).Value = rs.Fields("SSN") Then bFound = True rs.Edit rs.Fields("From") = Worksheets("Contacts").Cells(R, 3).Value rs.Fields("Type") = Worksheets("Contacts").Cells(R, 4).Value ' etc. rs.Update End If rs.MoveNext Loop Until rs.EOF Or bFound = True If bFound = False Then rs.AddNew rs.Fields("From") = Worksheets("Contacts").Cells(R, 3).Value rs.Fields("Type") = Worksheets("Contacts").Cells(R, 4).Vales ' etc. rs.Update End If Next R rs.Close Set rs = Nothing dbs.Close HTH, Merjet |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Help How to update linked .xls offline with MS-ACCESS (VB)? | Links and Linking in Excel | |||
Excel update from Access | Excel Discussion (Misc queries) | |||
export access to excel. change access & update excel at same time | Excel Discussion (Misc queries) | |||
Google Search Add-in update | Excel Worksheet Functions | |||
how do i loop in a access search | Excel Programming |