Filtering a form by integers

N

n1mbus

I have a form with a key that is a number field with a field size of 'single'.
How can I filter the form to show only the records where the key field is an
integer value.
 
N

n1mbus

That would do the job alright.
How would I code you code that into a button

Allen Browne said:
How about WHERE:
[Field1] - Int([Field1) = 0

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

n1mbus said:
I have a form with a key that is a number field with a field size of
'single'.
How can I filter the form to show only the records where the key field is
an
integer value.
 
N

n1mbus

command button code to filter by integer

Private Sub Command6_Click()
On Error GoTo Err_Command6_Click

Me.Filter = "[id] - Int([id]) = 0"
Me.FilterOn = True


Exit_Command6_Click:
Exit Sub

Err_Command6_Click:
MsgBox Err.Description
Resume Exit_Command6_Click


n1mbus said:
That would do the job alright.
How would I code you code that into a button

Allen Browne said:
How about WHERE:
[Field1] - Int([Field1) = 0

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

n1mbus said:
I have a form with a key that is a number field with a field size of
'single'.
How can I filter the form to show only the records where the key field is
an
integer value.
 
M

Michael Miller

I have a similar situation and tried your suggestion below, but it keeps
asking me for a value for both my fields, and even if I input the value, it
does not filter anyway.

I have a header form and a detail form.
There is a (No Issues) checkbox on the header that means that there is no
detail (Issues) present for the ProjectID that is in the header.

I have gone through about 4 iterations of this code, but this was my last try:
'note that these ProjectID's are Decimals (don't ask. designed by another
vendor)
'this code is located in form activate

Set frm = Me.frmProjectIssue.Form 'the detail form
'Me is the header form
frm.Filter = "Me.[ProjectId].Value - frm.[ProjectId].Value = 0"
frm.FilterOn = True

If frm.NewRecord Then 'no records found for filter 'OK
situation
frm.Filter = ""
frmFilterOn = True
Else 'records were found for ProjectID in
header 'NOT ok
frm.Filter = ""
frmFilterOn = True
... <code to present msgbox and uncheck the header checkbox>

Where am I going astray here and is there an easier way to check to see if
-any- matching (header ID = any detail) ID with the same value)?

Thanks.
--
MichaelM


Allen Browne said:
How about WHERE:
[Field1] - Int([Field1) = 0

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

n1mbus said:
I have a form with a key that is a number field with a field size of
'single'.
How can I filter the form to show only the records where the key field is
an
integer value.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top