checking part of the value in a field (1 Viewer)

dcobau

Registered User.
Local time
Tomorrow, 00:05
Joined
Mar 1, 2004
Messages
124
g'day,

I have a form with a text field (txtDirName) from which users can select a directory. The directory can be selected at random but must partially contain the value of either "Imports" or "Clearances" (eg. V:\ManufacturingData\Imports).


I want to make 1 of 2 buttons visible based on the value contained in txtDirName. To test the contents Iof the field I created a temporary button with code such as:

select case me!txtDirName

case "*import*"
msgbox "Imports"

case "*clearance*"
msgbox "Clearances"

case else
msgbox "Not valid"

end select

This code does not do anything. It's like the button had no code attached to it. Any ideas what I am doing wrong?

thanks

Dave
 

boblarson

Smeghead
Local time
Today, 07:05
Joined
Jan 12, 2001
Messages
32,059
Code:
Dim strValue as String

strValue = "NoValue"

If Instr(1,Me.txtDirName,"import",vbTextCompare) > 0 Then
strValue = "Import"
End If

If Instr(1, Me.txtDirName, "clearance", vbTextCompare) > 0 Then
strValue = "Clearance"
End If



Select Case strValue

Case "Import"
    MsgBox "Imports"

Case "Clearance"
msgbox "Clearances"

case else
msgbox "Not valid"

end select
 

dcobau

Registered User.
Local time
Tomorrow, 00:05
Joined
Mar 1, 2004
Messages
124
thanks for the quick reply Bob,

I changed your code slightly
If InStr(1, Me.txtDirName, "import", vbTextCompare) > 0 Then
strValue = "Import"
MsgBox strValue
End If

If InStr(1, Me.txtDirName, "clearance", vbTextCompare) > 0 Then
strValue = "Clearance"
MsgBox strValue
End If

when I click on the test button I get first "Imports" then "Clearances".

Shouldn't I get one or the other?

thanks

Dave
 

boblarson

Smeghead
Local time
Today, 07:05
Joined
Jan 12, 2001
Messages
32,059
Put a break point in and then step through (F8) the code to see what is happening at what time and what the values are.
 

dcobau

Registered User.
Local time
Tomorrow, 00:05
Joined
Mar 1, 2004
Messages
124
this is a bit crazy. If I have V:\etc.\Imports

I get the msg with "Imports"

If I have V:\etc\Clearances

I get both msg Imports and Clearances

checking the values in code shows both "import" and, after the step through, "clearances".
????
 

Users who are viewing this thread

Top Bottom