Form with filter

K

Khalil Handal

Hi,
I have a table with a form "frmdata" related to it so as to enter data. I
have created another form "frmSearch" to show only certain record depending
on a "BirthDate " field with format of Short Date with input Mask of
99/99/00;0

In the regular form "frmData" I entered 2 digit year and it is turned
automaticly to 4 digit year.

In the second form "frmSearch" I have the following code (on open event):

Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenForm "frmSearch1", acNormal, , [Birthdate] = "10/10/1964"
End Sub

Question 1:
When I open the form "frmSearch" NO record is shown. The date 10/10/1964
exists in the table. I can't find the reason why??

Question 2:
What changes should be made to the code if I want to have only record
between two different dates where the user will enter each of the dates??

Any help is appriciated.
 
B

Beetle

Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenForm "frmSearch1", acNormal, , [Birthdate] = "10/10/1964"
End Sub

The code above basically states that when you open "frmSearch" you want
Access to then open another form called "frmSearch1" and look for a record
where the birthdate field = 10/10/1964.
Question 1:
When I open the form "frmSearch" NO record is shown. The date 10/10/1964
exists in the table. I can't find the reason why??

That's probably because you are telling Access to find the record in
"frmSearch1", not in "frmSearch".
Question 2:
What changes should be made to the code if I want to have only record
between two different dates where the user will enter each of the dates??

You could use a popup dialog form. Check the following link for info:

http://office.microsoft.com/en-us/access/HA010345481033.aspx

HTH



Khalil Handal said:
Hi,
I have a table with a form "frmdata" related to it so as to enter data. I
have created another form "frmSearch" to show only certain record depending
on a "BirthDate " field with format of Short Date with input Mask of
99/99/00;0

In the regular form "frmData" I entered 2 digit year and it is turned
automaticly to 4 digit year.

In the second form "frmSearch" I have the following code (on open event):

Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenForm "frmSearch1", acNormal, , [Birthdate] = "10/10/1964"
End Sub

Question 1:
When I open the form "frmSearch" NO record is shown. The date 10/10/1964
exists in the table. I can't find the reason why??

Question 2:
What changes should be made to the code if I want to have only record
between two different dates where the user will enter each of the dates??

Any help is appriciated.
 
K

Khalil Handal

Hi,
Thanks for the notes.
I think I made a mistake : The form name is "frmSearch1" .
on the "on open" even of the form (frmSearch1) property i have the code
mentioned.
It is the same form not 2 different forms.

Hope this made it more clear.
I will check he link you gave and see what I can find.


Beetle said:
Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenForm "frmSearch1", acNormal, , [Birthdate] = "10/10/1964"
End Sub

The code above basically states that when you open "frmSearch" you want
Access to then open another form called "frmSearch1" and look for a record
where the birthdate field = 10/10/1964.
Question 1:
When I open the form "frmSearch" NO record is shown. The date 10/10/1964
exists in the table. I can't find the reason why??

That's probably because you are telling Access to find the record in
"frmSearch1", not in "frmSearch".
Question 2:
What changes should be made to the code if I want to have only record
between two different dates where the user will enter each of the dates??

You could use a popup dialog form. Check the following link for info:

http://office.microsoft.com/en-us/access/HA010345481033.aspx

HTH



Khalil Handal said:
Hi,
I have a table with a form "frmdata" related to it so as to enter data.
I
have created another form "frmSearch" to show only certain record
depending
on a "BirthDate " field with format of Short Date with input Mask of
99/99/00;0

In the regular form "frmData" I entered 2 digit year and it is turned
automaticly to 4 digit year.

In the second form "frmSearch" I have the following code (on open
event):

Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenForm "frmSearch1", acNormal, , [Birthdate] = "10/10/1964"
End Sub

Question 1:
When I open the form "frmSearch" NO record is shown. The date 10/10/1964
exists in the table. I can't find the reason why??

Question 2:
What changes should be made to the code if I want to have only record
between two different dates where the user will enter each of the dates??

Any help is appriciated.
 
B

Beetle

In that case, my next question would be why are you using a forms On Open
event to tell the form to open itself? It's already in the process of being
opened, you don't need to open it again.

A better option might be to create a parameter query based on your table,
and then use the query as the control source of your form. You can create a
parameter query that will prompt the user for values that you specify
everytime the form is opened. You can find plenty of online documentation
about parameter queries if you're not sure how to set it up. Just do a search.

Khalil Handal said:
Hi,
Thanks for the notes.
I think I made a mistake : The form name is "frmSearch1" .
on the "on open" even of the form (frmSearch1) property i have the code
mentioned.
It is the same form not 2 different forms.

Hope this made it more clear.
I will check he link you gave and see what I can find.


Beetle said:
Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenForm "frmSearch1", acNormal, , [Birthdate] = "10/10/1964"
End Sub

The code above basically states that when you open "frmSearch" you want
Access to then open another form called "frmSearch1" and look for a record
where the birthdate field = 10/10/1964.
Question 1:
When I open the form "frmSearch" NO record is shown. The date 10/10/1964
exists in the table. I can't find the reason why??

That's probably because you are telling Access to find the record in
"frmSearch1", not in "frmSearch".
Question 2:
What changes should be made to the code if I want to have only record
between two different dates where the user will enter each of the dates??

You could use a popup dialog form. Check the following link for info:

http://office.microsoft.com/en-us/access/HA010345481033.aspx

HTH



Khalil Handal said:
Hi,
I have a table with a form "frmdata" related to it so as to enter data.
I
have created another form "frmSearch" to show only certain record
depending
on a "BirthDate " field with format of Short Date with input Mask of
99/99/00;0

In the regular form "frmData" I entered 2 digit year and it is turned
automaticly to 4 digit year.

In the second form "frmSearch" I have the following code (on open
event):

Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenForm "frmSearch1", acNormal, , [Birthdate] = "10/10/1964"
End Sub

Question 1:
When I open the form "frmSearch" NO record is shown. The date 10/10/1964
exists in the table. I can't find the reason why??

Question 2:
What changes should be made to the code if I want to have only record
between two different dates where the user will enter each of the dates??

Any help is appriciated.
 
K

Khalil Handal

The idea is related to "filtering" not seeing all the records, only see
records that satisfay a certain criteria avoiding using queries.
I have already started documentation on parameter queries.

Thanks for the help.


Beetle said:
In that case, my next question would be why are you using a forms On Open
event to tell the form to open itself? It's already in the process of
being
opened, you don't need to open it again.

A better option might be to create a parameter query based on your table,
and then use the query as the control source of your form. You can create
a
parameter query that will prompt the user for values that you specify
everytime the form is opened. You can find plenty of online documentation
about parameter queries if you're not sure how to set it up. Just do a
search.

Khalil Handal said:
Hi,
Thanks for the notes.
I think I made a mistake : The form name is "frmSearch1" .
on the "on open" even of the form (frmSearch1) property i have the code
mentioned.
It is the same form not 2 different forms.

Hope this made it more clear.
I will check he link you gave and see what I can find.


Beetle said:
Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenForm "frmSearch1", acNormal, , [Birthdate] = "10/10/1964"
End Sub

The code above basically states that when you open "frmSearch" you want
Access to then open another form called "frmSearch1" and look for a
record
where the birthdate field = 10/10/1964.

Question 1:
When I open the form "frmSearch" NO record is shown. The date
10/10/1964
exists in the table. I can't find the reason why??

That's probably because you are telling Access to find the record in
"frmSearch1", not in "frmSearch".

Question 2:
What changes should be made to the code if I want to have only record
between two different dates where the user will enter each of the
dates??

You could use a popup dialog form. Check the following link for info:

http://office.microsoft.com/en-us/access/HA010345481033.aspx

HTH



:

Hi,
I have a table with a form "frmdata" related to it so as to enter
data.
I
have created another form "frmSearch" to show only certain record
depending
on a "BirthDate " field with format of Short Date with input Mask of
99/99/00;0

In the regular form "frmData" I entered 2 digit year and it is turned
automaticly to 4 digit year.

In the second form "frmSearch" I have the following code (on open
event):

Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenForm "frmSearch1", acNormal, , [Birthdate] = "10/10/1964"
End Sub

Question 1:
When I open the form "frmSearch" NO record is shown. The date
10/10/1964
exists in the table. I can't find the reason why??

Question 2:
What changes should be made to the code if I want to have only record
between two different dates where the user will enter each of the
dates??

Any help is appriciated.
 

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