How to check if two objects have the same property values

JONeill

Board Regular
Joined
Sep 2, 2018
Messages
58
I'm trying to avoid a complicated if statement so, I'm trying to find an easy way to compare the property values of two objects. Not the same reference but the values. There's gotta be a way to do that. Thus far, I haven't found anything but Is and IsNot operators.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
So, I'm checking to see if a user has made any changes during an edit on a form. To fill the form, I get the chosen record out of the collection and place the values in currentRecord. I then check that against the form values to see if they are different. If they are, a message box pops up asking for confirmation when they want to cancel or exit.

I'm currently doing something like this...

if tmpRec.LastName = currentRecord.LastName And _
tmpRec.FirstName = tmpRec.FirstName And _

so on and so forth...

What I'd like to do is something like this...

if tmpRec = currentRecord then

I'm getting an error when I do that. Something about not supporting the property or method
 
Upvote 0
Are you creating an object for the values on the form?
 
Upvote 0
I know you can check for object 'equivalency' using the Is operator but I think that only works when you have 2 separate references to the same object.
 
Upvote 0
I haven't seen anything that allows you to check properties in one statement either. Seems there should be a way to do that. I'm not even sure you could write something that does that since you can't traverse through an objects properties unless you know them in advance.
 
Upvote 0

Forum statistics

Threads
1,224,879
Messages
6,181,531
Members
453,054
Latest member
ezzat

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top