Coding Issues

J

James

Hello I have 2 problems both related to the same form.

Right heres what I have got:

I have 3 forms and on main form.... The main form has a
combo box which has three values. Each value corrisponds
to one of the forms and pulls up the relevant form. Then
when you select another option from the combo box i9t
again pulls up the relevant form and hides the previous
form. This is all for a search form. I have created a
UNION query with help from some MVP's (Thanks again guys)
and I have based the main form on that UNION query. This
is because it joins 4 tables together. Ok now when I open
the main form I get a combo box at the top and two
buttons... One of which exits the form and the other which
searched the current form...

Now when I open one of the forms from the combo box all
the records seem to be displayed. This I dont want as its
a pointless excersise having to trall through all the
records which are displayed when I have the search
facility which is much more efficiant and less time
consuming. So my first question would be how do I stop all
the records from being shown?

The next one is within the coding for the seach facility...

I have the following:

FilterMe = "[id] > 0"

If chkcisco1 Then FilterMe = FilterMe & " AND [Forname]
= " & cbocisco1

DoCmd.ApplyFilter , FilterMe

End Sub

On the On Click command of the search records button.
Obviously I have more lines of this same code but with teh
fields names changed? Is this code right? if not how can I
correct it so that it searched the relevant records?

Many Thanks and your help will be appreciated

James
..
 
J

James

Please could you explain further as I dont think I quite
understand where your coming from? The form will be opend
by a cmd button so in the code your asking me to put the
below code? If so how will it stop all the records showing
and not just the one with the ID of 500? Also do you have
any suggestions on the other problem I was having?

Many Thanks for this

James
-----Original Message-----
Use the Forms Where clause while opening it instead of a filter. When you
use the Where clause it will restrict the data in the underlaying SQL.
DoCmd.OpenForm "SomeForm",,,"ID = 500"

--
Kindest regards
HC Francke
www.master-office.com

"James" <[email protected]> skrev i melding
Hello I have 2 problems both related to the same form.

Right heres what I have got:

I have 3 forms and on main form.... The main form has a
combo box which has three values. Each value corrisponds
to one of the forms and pulls up the relevant form. Then
when you select another option from the combo box i9t
again pulls up the relevant form and hides the previous
form. This is all for a search form. I have created a
UNION query with help from some MVP's (Thanks again guys)
and I have based the main form on that UNION query. This
is because it joins 4 tables together. Ok now when I open
the main form I get a combo box at the top and two
buttons... One of which exits the form and the other which
searched the current form...

Now when I open one of the forms from the combo box all
the records seem to be displayed. This I dont want as its
a pointless excersise having to trall through all the
records which are displayed when I have the search
facility which is much more efficiant and less time
consuming. So my first question would be how do I stop all
the records from being shown?

The next one is within the coding for the seach facility...

I have the following:

FilterMe = "[id] > 0"

If chkcisco1 Then FilterMe = FilterMe & " AND [Forname]
= " & cbocisco1

DoCmd.ApplyFilter , FilterMe

End Sub

On the On Click command of the search records button.
Obviously I have more lines of this same code but with teh
fields names changed? Is this code right? if not how can I
correct it so that it searched the relevant records?

Many Thanks and your help will be appreciated

James
.


.
 
J

James

Ok then so if I were to put ID = NULL would that return
nothing at all?

Cheers

James
-----Original Message-----
Thats right, using the where clause will restrict the records in the
underlaying query. You can use the
DoCmd.Openform "SomeForm",,,,"ID=500"
even if the form is open. It returns the record with ID = 500 and none else.


--
Kindest regards
HC Francke
www.master-office.com

"James" <[email protected]> skrev i melding
Please could you explain further as I dont think I quite
understand where your coming from? The form will be opend
by a cmd button so in the code your asking me to put the
below code? If so how will it stop all the records showing
and not just the one with the ID of 500? Also do you have
any suggestions on the other problem I was having?

Many Thanks for this

James
-----Original Message-----
Use the Forms Where clause while opening it instead of
a
filter. When you
use the Where clause it will restrict the data in the underlaying SQL.
DoCmd.OpenForm "SomeForm",,,"ID = 500"

--
Kindest regards
HC Francke
www.master-office.com

"James" <[email protected]> skrev i melding
Hello I have 2 problems both related to the same form.

Right heres what I have got:

I have 3 forms and on main form.... The main form has a
combo box which has three values. Each value corrisponds
to one of the forms and pulls up the relevant form. Then
when you select another option from the combo box i9t
again pulls up the relevant form and hides the previous
form. This is all for a search form. I have created a
UNION query with help from some MVP's (Thanks again guys)
and I have based the main form on that UNION query. This
is because it joins 4 tables together. Ok now when I open
the main form I get a combo box at the top and two
buttons... One of which exits the form and the other which
searched the current form...

Now when I open one of the forms from the combo box all
the records seem to be displayed. This I dont want as its
a pointless excersise having to trall through all the
records which are displayed when I have the search
facility which is much more efficiant and less time
consuming. So my first question would be how do I
stop
all
the records from being shown?

The next one is within the coding for the seach facility...

I have the following:

FilterMe = "[id] > 0"

If chkcisco1 Then FilterMe = FilterMe & " AND [Forname]
= " & cbocisco1

DoCmd.ApplyFilter , FilterMe

End Sub

On the On Click command of the search records button.
Obviously I have more lines of this same code but
with
teh
fields names changed? Is this code right? if not how can I
correct it so that it searched the relevant records?

Many Thanks and your help will be appreciated

James
.




.


.
 
J

James

Ok I have a question about this...

I am running the forms as sub forms how can I encorporate
thisinto this scenario? What happens is a user selects a
value from my combo box which then opens the relevant form
as a sub form. How can I do what is being asked with then
as a sub form?

Many Thanks

James
-----Original Message-----
Yes, unless you should have some records with ID = Null. If you use a
counter this should not be the case

--
Kindest regards
HC Francke
www.master-office.com

"James" <[email protected]> skrev i melding
Ok then so if I were to put ID = NULL would that return
nothing at all?

Cheers

James
-----Original Message-----
Thats right, using the where clause will restrict the records in the
underlaying query. You can use the
DoCmd.Openform "SomeForm",,,,"ID=500"
even if the form is open. It returns the record with
ID =
500 and none else.
--
Kindest regards
HC Francke
www.master-office.com

"James" <[email protected]> skrev i melding
Please could you explain further as I dont think I quite
understand where your coming from? The form will be opend
by a cmd button so in the code your asking me to put the
below code? If so how will it stop all the records showing
and not just the one with the ID of 500? Also do you have
any suggestions on the other problem I was having?

Many Thanks for this

James
-----Original Message-----
Use the Forms Where clause while opening it instead
of
a
filter. When you
use the Where clause it will restrict the data in the
underlaying SQL.
DoCmd.OpenForm "SomeForm",,,"ID = 500"

--
Kindest regards
HC Francke
www.master-office.com

"James" <[email protected]> skrev i
melding
Hello I have 2 problems both related to the same form.

Right heres what I have got:

I have 3 forms and on main form.... The main form has a
combo box which has three values. Each value corrisponds
to one of the forms and pulls up the relevant
form.
Then
when you select another option from the combo box i9t
again pulls up the relevant form and hides the previous
form. This is all for a search form. I have
created
a
UNION query with help from some MVP's (Thanks again
guys)
and I have based the main form on that UNION
query.
This
is because it joins 4 tables together. Ok now when I
open
the main form I get a combo box at the top and two
buttons... One of which exits the form and the other
which
searched the current form...

Now when I open one of the forms from the combo
box
all
the records seem to be displayed. This I dont want as
its
a pointless excersise having to trall through all the
records which are displayed when I have the search
facility which is much more efficiant and less time
consuming. So my first question would be how do I stop
all
the records from being shown?

The next one is within the coding for the seach
facility...

I have the following:

FilterMe = "[id] > 0"

If chkcisco1 Then FilterMe = FilterMe & " AND [Forname]
= " & cbocisco1

DoCmd.ApplyFilter , FilterMe

End Sub

On the On Click command of the search records button.
Obviously I have more lines of this same code but with
teh
fields names changed? Is this code right? if not how
can I
correct it so that it searched the relevant records?

Many Thanks and your help will be appreciated

James
.




.



.


.
 

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