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
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Is combobox rowsource type = table/query? If so, is the column count more than 1? If that is the case, the actual value of the combobox will be the first column, which might just be the record ID and not the value of "CLIENT1." I have had that happen to me before but not sure why.
 
Upvote 0
Check to make sure it really returns what you think it should. If you are looking for the value, then the bound column needs to be set to the correct column.

Put

Debug.Print Me.Combo6.Value

in the code and then look to see exactly what is coming out (in the Immediate Window).
 
Upvote 0
I debug.print and also check the combo source it is from query which is just one field selected. When I run it retuned "CLIENT1" in debug.print as well as msgbox.
No it is not always upper. it is Proper Mostly.

Thanks again
 
Upvote 0
Maybe

Code:
If UCase(Trim(Me.Combo6.Value)) = "CLIENT1" Then
 
Upvote 0

Code:
If UCase(Trim(Me.Combo6.Value)) = "CLIENT1" Then


I think "CLIENT1" and "Client1" should return as true...
May be something is wrong with my combo source....'ll recheck again and then come back::) Before going back and changing i thought i should check....thought maybe things are different in access:

Thanks again.
 
Upvote 0
Text comparison in VBA is case sensitive, unless you specify Option Compare Text at the top of the code module.
 
Upvote 0
Text comparison in VBA is case sensitive, unless you specify Option Compare Text at the top of the code module.

Umm, not that I've ever seen. It is normally Case INsensitive unless you use
Option Compare Binary
 
Upvote 0
Perhaps it's different in Access.

In the Excel VBE Immediate window,

? "Bob" = "bob"

returns False.
 
Upvote 0

Forum statistics

Threads
1,224,558
Messages
6,179,512
Members
452,920
Latest member
jaspers

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