VBA Function or SQL - compare 2 records in same table as Same or Needs Update (1 Viewer)

Rx_

Nothing In Moderation
Local time
Today, 15:42
Joined
Oct 22, 2009
Messages
2,803
Would a custom VBA function on a Recordset be best or is there another approach such as a SQL Statement?

See Attachment:
The user chooses a customer Order in listbox1 and 2nd Customer in Listbox2

The Order1 is compared with similar Category and Inspector for the records of Custtomer in Listbox2 (Target)

The question of:
Does the Target match the primary? If so, nothing need to be done.
If the Target is "close" but missing data in a field or two, then update the target with the same data in those missing fields.

My feeling is that a custom function that has a loop to review the Columns will be necessary.

However, if some one has a better suggestion, for example a SQL Statement, it would be great to learn something new.
 

Attachments

  • FieldWorkDates-Replicate-Update-Records.gif
    FieldWorkDates-Replicate-Update-Records.gif
    58.1 KB · Views: 93

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 16:42
Joined
Feb 28, 2001
Messages
27,258
Looking at this from a purely functional standpoint, SQL isn't the answer because SQL does not return anything to you directly. A VBA function, on the other hand, provides any kind of status code you wish, such as "User needs to update" or "User can let sleeping dog lie" or "User is out somewhere in left field" - or whatever status is appropriate to your situation.

The issue has NOTHING to do with whether SQL could be made to evaluate the condition and more that you have something else to do after a specific condition is detected - which means you would need a second step after executing the SQL anyway.
 

Rx_

Nothing In Moderation
Local time
Today, 15:42
Joined
Oct 22, 2009
Messages
2,803
Have been working on it for the morning, same conclusion.
Created a local table - use a query to add the first record from Listbox1
The rest of the records 0 to many - are candidates for the target.

From that point, some nested Select Case statements evaluate row by row, column by column.

Perhaps a letter to the SQL standards group to recommend a "CloseEnough" operator to be added to the language.
 

Users who are viewing this thread

Top Bottom