Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

comparing fields, one populated with data and one blank 2

Status
Not open for further replies.

atadbitslow

Programmer
Feb 26, 2001
301
0
0
US
Hi,
I have two subforms on a form and I have VBA code that compares the fields on one subform to the other subform. If the fields don't match, I have a button for the user to click on to update the data in the field that doesn't match. It's basically:
If [subform1]![fielda]<>[subform2]![fielda] then
me.updatebtn.visible=true
end if

This works fine, unless [subform1]![fielda] has data and [subform2]![fielda] does not have data. It doesn't recognize that they don't match. I'm pretty sure this is dumb question, but why is that? Is there a way to get it to recognize they don't match?
Thank you!
 
Could you 'translate' your issue from: 'fields on the forms' to 'fields in tables in the data base'?

Are you saying: Fields in TableA do not match fields in TableB?
If that is the case, my question will be: why do you have the data in more than just one place in your data base? Unless your issue is something else
[ponder]

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Thanks for your response. The question is why when comparing data in one field in a table to a field in a different table that has no data, why are the two fields not being recognized as being unequal?
 
atadbitslow said:
[subform2]![fielda] does not have data

You may try something like:

Code:
If [subform1]![fielda][blue] & "" [/blue]<> [subform2]![fielda][blue] & "" [/blue] then
    me.updatebtn.visible=true
end if

In case any of these fields are [red]NULL[/red]s

Just a suggestion.

But, you still did not answer my question :-(

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Null is about the same as “ unknown”. You can’t compare unknown values using = or <>. You should convert the Nulls using NZ() and then compare.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Thank you both very much! One table is imported data from our online dashboard and is used to update our existing data in our Access database. So not really same data in two places. The imported data table is cleared after each session.
 
So is your issue resolved? Did you attempt Andy’s suggestion which should work.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
I would rather use Duane's suggestion with NZ(), it is more 'elegant' IMO :)

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Hi,
I think I'll use NZ() which is what I thought of trying on my own, but didn't. I haven't updated the code just yet, will do today.
Thank you both!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top