If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
|
Thread Tools | Display Modes |
#11
|
|||
|
|||
If statement
Jason,
there seems to be some confusion. op = j3678 DLookup = j3678 These are both the same. When I test these using strComp I get 0 as the value. The 0 tells me that the value is the same as the value for DLookup. Which is what I expect. It seems to me that access is doing the right thing. The second test used op = j3678 DLookup = J3678 This returned a value of 1 which tells us that j3678 is not the same as J3678. In other words, the return value of 0 means that both strings are the same. The return value of 1 means that both strings are not the same. Does this help? Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... op: j3678 DLookup: j3678 "Jeanette Cunningham" wrote in message ... Jason, it would help if you would copy and paste the values into a post. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... I've done that using MsgBox - Debug window also still shows identical values. "Jeanette Cunningham" wrote in message ... Jason, in your code put some debug.print statements like this: Debug.Print "OP: " & OP Debug.Print "DLookup: " & DLookup("P", "S", "C = """ & SD & """") If StrComp(OP & "", DLookup("P", "S", "C = """ & SD & """"), 1) ... etc Run the code by opening the form in normal view and clicking the buttons etc. Now do Ctl + G to open the immediate window. You will see what values access got for OP and DLookup("P", "S", "C = """ & SD & """") This will be the clue to why it doesn't work. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... Still get the error: If StrComp(OP & "", DLookup("P", "S", "C = """ & SD & """"), 1) "Jeanette Cunningham" wrote in message ... Jason, did you change back to Option Compare Database Option Explicit ? If it still doesn't work, post a copy and paste of your code. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... The result is still false even though both MyStr1 = "ABCD" MyStr2 = "ABCD" "Jeanette Cunningham" wrote in message ... Jason, from access vba help. StrComp Function Example This example uses the StrComp function to return the results of a string comparison. If the third argument is 1, a textual comparison is performed; if the third argument is 0 or omitted, a binary comparison is performed. Dim MyStr1, MyStr2, MyComp MyStr1 = "ABCD": MyStr2 = "abcd" ' Define variables. MyComp = StrComp(MyStr1, MyStr2, 1) ' Returns 0. MyComp = StrComp(MyStr1, MyStr2, 0) ' Returns -1. MyComp = StrComp(MyStr2, MyStr1) ' Returns 1. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... How do I make lcase("A") = ucase("A") return false. I can perform the oposite in DOS/CMD (if /i A==a returns true, if A==a returns fasle ) but how is it done in Access? Thanks, J. |
#12
|
|||
|
|||
If statement
So returns false (0) when equal and true (not 0) when not equal. Shall try
different approach. "Jeanette Cunningham" wrote in message ... Jason, there seems to be some confusion. op = j3678 DLookup = j3678 These are both the same. When I test these using strComp I get 0 as the value. The 0 tells me that the value is the same as the value for DLookup. Which is what I expect. It seems to me that access is doing the right thing. The second test used op = j3678 DLookup = J3678 This returned a value of 1 which tells us that j3678 is not the same as J3678. In other words, the return value of 0 means that both strings are the same. The return value of 1 means that both strings are not the same. Does this help? Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... op: j3678 DLookup: j3678 "Jeanette Cunningham" wrote in message ... Jason, it would help if you would copy and paste the values into a post. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... I've done that using MsgBox - Debug window also still shows identical values. "Jeanette Cunningham" wrote in message ... Jason, in your code put some debug.print statements like this: Debug.Print "OP: " & OP Debug.Print "DLookup: " & DLookup("P", "S", "C = """ & SD & """") If StrComp(OP & "", DLookup("P", "S", "C = """ & SD & """"), 1) ... etc Run the code by opening the form in normal view and clicking the buttons etc. Now do Ctl + G to open the immediate window. You will see what values access got for OP and DLookup("P", "S", "C = """ & SD & """") This will be the clue to why it doesn't work. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... Still get the error: If StrComp(OP & "", DLookup("P", "S", "C = """ & SD & """"), 1) "Jeanette Cunningham" wrote in message ... Jason, did you change back to Option Compare Database Option Explicit ? If it still doesn't work, post a copy and paste of your code. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... The result is still false even though both MyStr1 = "ABCD" MyStr2 = "ABCD" "Jeanette Cunningham" wrote in message ... Jason, from access vba help. StrComp Function Example This example uses the StrComp function to return the results of a string comparison. If the third argument is 1, a textual comparison is performed; if the third argument is 0 or omitted, a binary comparison is performed. Dim MyStr1, MyStr2, MyComp MyStr1 = "ABCD": MyStr2 = "abcd" ' Define variables. MyComp = StrComp(MyStr1, MyStr2, 1) ' Returns 0. MyComp = StrComp(MyStr1, MyStr2, 0) ' Returns -1. MyComp = StrComp(MyStr2, MyStr1) ' Returns 1. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... How do I make lcase("A") = ucase("A") return false. I can perform the oposite in DOS/CMD (if /i A==a returns true, if A==a returns fasle ) but how is it done in Access? Thanks, J. |
#13
|
|||
|
|||
If statement
I've tried adding = 0 before then. Now it is saying that when J3678 is
entered it is equal and when j3678 is entered that is equal also. "Jeanette Cunningham" wrote in message ... Jason, there seems to be some confusion. op = j3678 DLookup = j3678 These are both the same. When I test these using strComp I get 0 as the value. The 0 tells me that the value is the same as the value for DLookup. Which is what I expect. It seems to me that access is doing the right thing. The second test used op = j3678 DLookup = J3678 This returned a value of 1 which tells us that j3678 is not the same as J3678. In other words, the return value of 0 means that both strings are the same. The return value of 1 means that both strings are not the same. Does this help? Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... op: j3678 DLookup: j3678 "Jeanette Cunningham" wrote in message ... Jason, it would help if you would copy and paste the values into a post. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... I've done that using MsgBox - Debug window also still shows identical values. "Jeanette Cunningham" wrote in message ... Jason, in your code put some debug.print statements like this: Debug.Print "OP: " & OP Debug.Print "DLookup: " & DLookup("P", "S", "C = """ & SD & """") If StrComp(OP & "", DLookup("P", "S", "C = """ & SD & """"), 1) ... etc Run the code by opening the form in normal view and clicking the buttons etc. Now do Ctl + G to open the immediate window. You will see what values access got for OP and DLookup("P", "S", "C = """ & SD & """") This will be the clue to why it doesn't work. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... Still get the error: If StrComp(OP & "", DLookup("P", "S", "C = """ & SD & """"), 1) "Jeanette Cunningham" wrote in message ... Jason, did you change back to Option Compare Database Option Explicit ? If it still doesn't work, post a copy and paste of your code. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... The result is still false even though both MyStr1 = "ABCD" MyStr2 = "ABCD" "Jeanette Cunningham" wrote in message ... Jason, from access vba help. StrComp Function Example This example uses the StrComp function to return the results of a string comparison. If the third argument is 1, a textual comparison is performed; if the third argument is 0 or omitted, a binary comparison is performed. Dim MyStr1, MyStr2, MyComp MyStr1 = "ABCD": MyStr2 = "abcd" ' Define variables. MyComp = StrComp(MyStr1, MyStr2, 1) ' Returns 0. MyComp = StrComp(MyStr1, MyStr2, 0) ' Returns -1. MyComp = StrComp(MyStr2, MyStr1) ' Returns 1. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... How do I make lcase("A") = ucase("A") return false. I can perform the oposite in DOS/CMD (if /i A==a returns true, if A==a returns fasle ) but how is it done in Access? Thanks, J. |
#14
|
|||
|
|||
If statement
Don't know what's going on
I have changed to: If StrComp(OP & "", DLookup("P", "S", "C = """ & SD & """"), 0) = 0 then This appears to work "Jeanette Cunningham" wrote in message ... Jason, there seems to be some confusion. op = j3678 DLookup = j3678 These are both the same. When I test these using strComp I get 0 as the value. The 0 tells me that the value is the same as the value for DLookup. Which is what I expect. It seems to me that access is doing the right thing. The second test used op = j3678 DLookup = J3678 This returned a value of 1 which tells us that j3678 is not the same as J3678. In other words, the return value of 0 means that both strings are the same. The return value of 1 means that both strings are not the same. Does this help? Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... op: j3678 DLookup: j3678 "Jeanette Cunningham" wrote in message ... Jason, it would help if you would copy and paste the values into a post. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... I've done that using MsgBox - Debug window also still shows identical values. "Jeanette Cunningham" wrote in message ... Jason, in your code put some debug.print statements like this: Debug.Print "OP: " & OP Debug.Print "DLookup: " & DLookup("P", "S", "C = """ & SD & """") If StrComp(OP & "", DLookup("P", "S", "C = """ & SD & """"), 1) ... etc Run the code by opening the form in normal view and clicking the buttons etc. Now do Ctl + G to open the immediate window. You will see what values access got for OP and DLookup("P", "S", "C = """ & SD & """") This will be the clue to why it doesn't work. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... Still get the error: If StrComp(OP & "", DLookup("P", "S", "C = """ & SD & """"), 1) "Jeanette Cunningham" wrote in message ... Jason, did you change back to Option Compare Database Option Explicit ? If it still doesn't work, post a copy and paste of your code. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... The result is still false even though both MyStr1 = "ABCD" MyStr2 = "ABCD" "Jeanette Cunningham" wrote in message ... Jason, from access vba help. StrComp Function Example This example uses the StrComp function to return the results of a string comparison. If the third argument is 1, a textual comparison is performed; if the third argument is 0 or omitted, a binary comparison is performed. Dim MyStr1, MyStr2, MyComp MyStr1 = "ABCD": MyStr2 = "abcd" ' Define variables. MyComp = StrComp(MyStr1, MyStr2, 1) ' Returns 0. MyComp = StrComp(MyStr1, MyStr2, 0) ' Returns -1. MyComp = StrComp(MyStr2, MyStr1) ' Returns 1. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... How do I make lcase("A") = ucase("A") return false. I can perform the oposite in DOS/CMD (if /i A==a returns true, if A==a returns fasle ) but how is it done in Access? Thanks, J. |
#15
|
|||
|
|||
If statement
Jason,
it's morning here and I am back on the discussion group. I think it's easier to understand the code when it is written differently. Here's an example Dim lngReturnValue as Long lngReturnValue = StrComp(OP & "", DLookup("P", "S", "C = """ & SD & """"), 0) Debug.Print lngReturnValue If Len(lngReturnValue) 0 Then If lngReturnValue = 0 Then 'code here with action to take ElseIf lngReturnValue = 1 Then 'code here with other action to take Else 'code here with other action to take End If End If The 3 parts of the if statement cover the 3 possible return values. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... Don't know what's going on I have changed to: If StrComp(OP & "", DLookup("P", "S", "C = """ & SD & """"), 0) = 0 then This appears to work "Jeanette Cunningham" wrote in message ... Jason, there seems to be some confusion. op = j3678 DLookup = j3678 These are both the same. When I test these using strComp I get 0 as the value. The 0 tells me that the value is the same as the value for DLookup. Which is what I expect. It seems to me that access is doing the right thing. The second test used op = j3678 DLookup = J3678 This returned a value of 1 which tells us that j3678 is not the same as J3678. In other words, the return value of 0 means that both strings are the same. The return value of 1 means that both strings are not the same. Does this help? Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... op: j3678 DLookup: j3678 "Jeanette Cunningham" wrote in message ... Jason, it would help if you would copy and paste the values into a post. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... I've done that using MsgBox - Debug window also still shows identical values. "Jeanette Cunningham" wrote in message ... Jason, in your code put some debug.print statements like this: Debug.Print "OP: " & OP Debug.Print "DLookup: " & DLookup("P", "S", "C = """ & SD & """") If StrComp(OP & "", DLookup("P", "S", "C = """ & SD & """"), 1) ... etc Run the code by opening the form in normal view and clicking the buttons etc. Now do Ctl + G to open the immediate window. You will see what values access got for OP and DLookup("P", "S", "C = """ & SD & """") This will be the clue to why it doesn't work. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... Still get the error: If StrComp(OP & "", DLookup("P", "S", "C = """ & SD & """"), 1) "Jeanette Cunningham" wrote in message ... Jason, did you change back to Option Compare Database Option Explicit ? If it still doesn't work, post a copy and paste of your code. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... The result is still false even though both MyStr1 = "ABCD" MyStr2 = "ABCD" "Jeanette Cunningham" wrote in message ... Jason, from access vba help. StrComp Function Example This example uses the StrComp function to return the results of a string comparison. If the third argument is 1, a textual comparison is performed; if the third argument is 0 or omitted, a binary comparison is performed. Dim MyStr1, MyStr2, MyComp MyStr1 = "ABCD": MyStr2 = "abcd" ' Define variables. MyComp = StrComp(MyStr1, MyStr2, 1) ' Returns 0. MyComp = StrComp(MyStr1, MyStr2, 0) ' Returns -1. MyComp = StrComp(MyStr2, MyStr1) ' Returns 1. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... How do I make lcase("A") = ucase("A") return false. I can perform the oposite in DOS/CMD (if /i A==a returns true, if A==a returns fasle ) but how is it done in Access? Thanks, J. |
#16
|
|||
|
|||
If statement
The one line statement works fine. However, I notice that you have also
changed the third number from 1 to 0. Why is Len(lngReturnValue) required? looks like you are trying to get the string length from an integer. "Jeanette Cunningham" wrote in message ... Jason, it's morning here and I am back on the discussion group. I think it's easier to understand the code when it is written differently. Here's an example Dim lngReturnValue as Long lngReturnValue = StrComp(OP & "", DLookup("P", "S", "C = """ & SD & """"), 0) Debug.Print lngReturnValue If Len(lngReturnValue) 0 Then If lngReturnValue = 0 Then 'the values are the same - process ElseIf lngReturnValue = 1 Then 'msgbox "error" Else 'something's wrong End If End If The 3 parts of the if statement cover the 3 possible return values. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... Don't know what's going on I have changed to: If StrComp(OP & "", DLookup("P", "S", "C = """ & SD & """"), 0) = 0 then This appears to work "Jeanette Cunningham" wrote in message ... Jason, there seems to be some confusion. op = j3678 DLookup = j3678 These are both the same. When I test these using strComp I get 0 as the value. The 0 tells me that the value is the same as the value for DLookup. Which is what I expect. It seems to me that access is doing the right thing. The second test used op = j3678 DLookup = J3678 This returned a value of 1 which tells us that j3678 is not the same as J3678. In other words, the return value of 0 means that both strings are the same. The return value of 1 means that both strings are not the same. Does this help? Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... op: j3678 DLookup: j3678 "Jeanette Cunningham" wrote in message ... Jason, it would help if you would copy and paste the values into a post. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... I've done that using MsgBox - Debug window also still shows identical values. "Jeanette Cunningham" wrote in message ... Jason, in your code put some debug.print statements like this: Debug.Print "OP: " & OP Debug.Print "DLookup: " & DLookup("P", "S", "C = """ & SD & """") If StrComp(OP & "", DLookup("P", "S", "C = """ & SD & """"), 1) .... etc Run the code by opening the form in normal view and clicking the buttons etc. Now do Ctl + G to open the immediate window. You will see what values access got for OP and DLookup("P", "S", "C = """ & SD & """") This will be the clue to why it doesn't work. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... Still get the error: If StrComp(OP & "", DLookup("P", "S", "C = """ & SD & """"), 1) "Jeanette Cunningham" wrote in message ... Jason, did you change back to Option Compare Database Option Explicit ? If it still doesn't work, post a copy and paste of your code. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... The result is still false even though both MyStr1 = "ABCD" MyStr2 = "ABCD" "Jeanette Cunningham" wrote in message ... Jason, from access vba help. StrComp Function Example This example uses the StrComp function to return the results of a string comparison. If the third argument is 1, a textual comparison is performed; if the third argument is 0 or omitted, a binary comparison is performed. Dim MyStr1, MyStr2, MyComp MyStr1 = "ABCD": MyStr2 = "abcd" ' Define variables. MyComp = StrComp(MyStr1, MyStr2, 1) ' Returns 0. MyComp = StrComp(MyStr1, MyStr2, 0) ' Returns -1. MyComp = StrComp(MyStr2, MyStr1) ' Returns 1. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... How do I make lcase("A") = ucase("A") return false. I can perform the oposite in DOS/CMD (if /i A==a returns true, if A==a returns fasle ) but how is it done in Access? Thanks, J. |
#17
|
|||
|
|||
If statement
Jason,
Len(lngReturnValue) is a way of testing whether the result of strComp is Null. So in a sense there are 4 possible values from the strComp function. It makes sense to cover all 4 possibilities in your code in order to cover for any errors due to unforseen values for OP or the DLookup. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... The one line statement works fine. However, I notice that you have also changed the third number from 1 to 0. Why is Len(lngReturnValue) required? looks like you are trying to get the string length from an integer. "Jeanette Cunningham" wrote in message ... Jason, it's morning here and I am back on the discussion group. I think it's easier to understand the code when it is written differently. Here's an example Dim lngReturnValue as Long lngReturnValue = StrComp(OP & "", DLookup("P", "S", "C = """ & SD & """"), 0) Debug.Print lngReturnValue If Len(lngReturnValue) 0 Then If lngReturnValue = 0 Then 'the values are the same - process ElseIf lngReturnValue = 1 Then 'msgbox "error" Else 'something's wrong End If End If The 3 parts of the if statement cover the 3 possible return values. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... Don't know what's going on I have changed to: If StrComp(OP & "", DLookup("P", "S", "C = """ & SD & """"), 0) = 0 then This appears to work "Jeanette Cunningham" wrote in message ... Jason, there seems to be some confusion. op = j3678 DLookup = j3678 These are both the same. When I test these using strComp I get 0 as the value. The 0 tells me that the value is the same as the value for DLookup. Which is what I expect. It seems to me that access is doing the right thing. The second test used op = j3678 DLookup = J3678 This returned a value of 1 which tells us that j3678 is not the same as J3678. In other words, the return value of 0 means that both strings are the same. The return value of 1 means that both strings are not the same. Does this help? Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... op: j3678 DLookup: j3678 "Jeanette Cunningham" wrote in message ... Jason, it would help if you would copy and paste the values into a post. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... I've done that using MsgBox - Debug window also still shows identical values. "Jeanette Cunningham" wrote in message ... Jason, in your code put some debug.print statements like this: Debug.Print "OP: " & OP Debug.Print "DLookup: " & DLookup("P", "S", "C = """ & SD & """") If StrComp(OP & "", DLookup("P", "S", "C = """ & SD & """"), 1) ... etc Run the code by opening the form in normal view and clicking the buttons etc. Now do Ctl + G to open the immediate window. You will see what values access got for OP and DLookup("P", "S", "C = """ & SD & """") This will be the clue to why it doesn't work. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... Still get the error: If StrComp(OP & "", DLookup("P", "S", "C = """ & SD & """"), 1) "Jeanette Cunningham" wrote in message ... Jason, did you change back to Option Compare Database Option Explicit ? If it still doesn't work, post a copy and paste of your code. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... The result is still false even though both MyStr1 = "ABCD" MyStr2 = "ABCD" "Jeanette Cunningham" wrote in message ... Jason, from access vba help. StrComp Function Example This example uses the StrComp function to return the results of a string comparison. If the third argument is 1, a textual comparison is performed; if the third argument is 0 or omitted, a binary comparison is performed. Dim MyStr1, MyStr2, MyComp MyStr1 = "ABCD": MyStr2 = "abcd" ' Define variables. MyComp = StrComp(MyStr1, MyStr2, 1) ' Returns 0. MyComp = StrComp(MyStr1, MyStr2, 0) ' Returns -1. MyComp = StrComp(MyStr2, MyStr1) ' Returns 1. Jeanette Cunningham -- Melbourne Victoria Australia "Jason" wrote in message ... How do I make lcase("A") = ucase("A") return false. I can perform the oposite in DOS/CMD (if /i A==a returns true, if A==a returns fasle ) but how is it done in Access? Thanks, J. |
|
Thread Tools | |
Display Modes | |
|
|