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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Expression using AND, OR 2

Status
Not open for further replies.

jgeneie

Technical User
Feb 20, 2002
41
0
0
SG
hi all,

i have a problem displaying my results.

i have created a table with 3 fields: "customername","dealers" and "ISP"

-customername will store names of customer( obviously )
- ISP and dealers data type are just yes/no

lets say i have created a OR expression between "dealers" and "ISP". when i select "dealers" and "ISP".

customername dealers ISP
------------ ------- ---
bob yes yes
cat yes
dog yes

but all i want is BOB's name to appear.

But lets say i use AND expression instead and select the same 2 fields: dealers and ISP

customername dealers ISP
------------ ------- ---
bob yes yes

that will satify my criteria but lets say i only select "dealers", "bob" name will not appear but instead only
"dog" will appear.

thats not i expect, i expect "dog" and "Bob" to appear.

how do i solve this problem using expressions?
 
thanks jim, u have been a great help

i couldnt have completed my task without u

regards
jgeneie
 
hi jim,

juz a little question on input mask.
1)Can i use input mask to force the first letter of a word to become a capital letter when a user enters in a txt box??

2)what can do to prevent duplicate records being stored. like mayb a pop up msgbox stating " duplicate record"

thanks

 
hi jim,

juz a little question on input mask.
1)Can i use input mask to force the first letter of a word to become a capital letter when a user enters in a txt box??

2)what can do to prevent duplicate records being stored. like mayb a pop up msgbox stating " duplicate record"

thanks

 
jgeneie,
An input mask could be used, but you need to put in a set number of characters with a placeholder. I prefer:

Private Sub LastName_KeyPress(KeyAscii As Integer)
On Error Resume Next
'CONVERT TO UPPER CASE
If KeyAscii >= 97 And KeyAscii <= 122 Then
KeyAscii = KeyAscii - 32 'subtract 32, this is the offset from upper-lower case
End If
End Sub

But what if you have dozens of fields? See below:
Sub Generate()
Dim f As Form, i As Integer
Set f = Forms!customer_master
For i = 0 To f.Controls.Count - 1
If TypeOf f(i) Is TextBox Then
Debug.Print &quot;Private Sub &quot; & f(i).Name & &quot;_KeyPress(KeyAscii As Integer)&quot;
Debug.Print &quot;On Error Resume Next&quot;
Debug.Print &quot;'CONVERT TO UPPER CASE&quot;
Debug.Print &quot;On Error Resume Next&quot;
Debug.Print &quot; If KeyAscii >= 97 And KeyAscii <= 122 Then&quot;
Debug.Print &quot; KeyAscii = KeyAscii - 32&quot;
Debug.Print &quot; End If&quot;
Debug.Print &quot;End Sub&quot;
End If
Next i
End Sub

Take the immediate window (debug window) output and cut/paste it into the forms module. You can use this for any form event where you have alot of code that you want to put in some event, and you don't want to set the event procedure to

[event procedure]
=SomeFunction()

...SomeFunction() would do the same as the above, but you have to deal with what the active control is (screen.activecontrol is not always reliable), and what if you want arguements. The direct code is preferable, in my opinion.
--Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top