Why is this happening: If Me.Combo6.Value = "CLIENT1" Then wont work

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Hi, I know that Combo6 value = CLIENT1 withot any spaces...
however it always returns "MsgBox "No " & Me.Combo6.Value
I also tried If trim(Me.Combo6.Value) = "CLIENT1" Then
Still the same...

Is there some reason this can happen in access form?

Thanks for helping.
Code:
[/FONT]
[FONT=Courier New]Option Compare Database[/FONT]
[FONT=Courier New]Private Sub Command8_Click()
 If Me.Combo6.Value = "CLIENT1" Then
 MsgBox "Yes " & Me.Combo6.Value
 Else
 MsgBox "No " & Me.Combo6.Value
 End If
End Sub
 
use the StrComp function if you want a robust solution ...
Got that, do that, done that.

My point was just to understand if the intrinsic VBA behavior is different between Excel and Access, and it seems that the answer is no, they are the same, but Option Compare Database, apparently always used in Access, has has the same (or broader) effects as Option Compare Text.
 
Upvote 0

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
And one more page that recommends a) generally use Option Compare Database to respect the sort order of the database in Access databases and b) use the StrComp function if you want a robust solution that works the same no matter what Option Compare is used ... (I think this is what dk was saying above).
http://www.fmsinc.com/free/NewTips/VBA/Option/index.html

Yes, that's exactly what I was saying. Same with using Option Base 1 - I'd rather just use Lbound and Ubound so that way I can safely reuse functions (across Excel, Access, Word) and not have to worry about whether I have the correct module level settings.
 
Upvote 0

Forum statistics

Threads
1,224,560
Messages
6,179,520
Members
452,923
Latest member
JackiG

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