Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Lin100
Yak Posting Veteran
70 Posts |
Posted - 2006-11-09 : 04:17:36
|
How to have the Seek function to seek for a value on two fields. I had two tables as shown below. I wanted to compare the field NAI_UNIT_NUMBER in the NAI_TABLEto the field NAI_UNIT_NUMBER and to the field NEW_UNIT_NUMBER in the UNIT_REFERENCE_TABLE. If there is a match in either of the two fields, then it will write a message to the field RESULT_OF_MATCH in the NAI_TABLE.For example. The record with a NAI_UNIT_NUMBER (001000) in the NAI_TABLE will resulta match of 001000 in the UNIT_REFERENCE_TABLE.The record with a NAI_UNIT_NUMBER (002000) in the NAI_TABLE will resulta match of 002000 in the UNIT_REFERENCE_TABLE.The record with a NAI_UNIT_NUMBER (007534) in the NAI_TABLE will not result in a match in either fields of the UNIT_REFERENCE_TABLE.When I did a seek, Access did find a match for value 001000, and 002000 butfor the value 007534, it did not perform a seek. I know that it didnot perform a seek because the message "There is No Match" was notwritten to the field RESULT_OF_MATCH.QUESTION:How do I have the seek function to search on both fields:NAI_UNIT_NUMBER and NEW_UNIT_NUMBER. If the valueappear in either of the two fields, then there is a match. If thevalue do not appear in any of the two fields, then there is no match ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Table Name: NAI_TABLENAI_UNIT_NUMBER RESULT_OF_MATCH001000 There is a match in the field NAI_UNIT_NUMBER002000 There is a match in the field NEW_UNIT_NUMBER007534 There is No Match <----------- ACCESS DID NOT WRITE THIS TEXT////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Table Name: UNIT_REFERENCE_TABLENAI_UNIT_NUMBER NEW_UNIT_NUMBER001000 00400000ABC 002000The UNIT_TABLE has an index named NAI_And_New_Unit_Number.This index is comprises of two fields: NAI_UNIT_NUMBER and NEW_UNIT_NUMBER.//////////////////////////////////////////////////////////With Recordset_Unit_Table.Index = "NAI_And_New_Unit_Number".Seek ">=", Var_Unit_NumberEnd With |
|
|
|
|