Search and display multiple records

A

Alex White MCDBA MCSE

Hi,

couple of things,

strSQL = "Select * from Daily_Report Where Origin Like " & chr(34) &
me.txtOrigin.value & "*" & chr(34)


you did remove the 1 before the last * in the line above?

and even though your sub form is called

Daily_Report_SubForm

if you type

Form_Origin_search.Daily_Report_Subform.Form


when you put the . on the end of that line do you get the context list come
up, because if you don't then it sounds like the subform has been renamed
once embeded on the main form, to check this right mouse click on the small
black frame around the subform when in design mode to get the properties of
the subform.


--
Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk

'green' said:
Hi Alex,

I manage to remove the error... but there is an run time error '424'
Oject Required.

What is this???
Pls advice

Thanks
Green

'green' said:
Hi Alex,

it is still unsuccessful... i don't think that is the problem...
is there any other way to change the "me." ? I'm thinking whether it is
the
problem.... but i may be wrong...

Best Regards
Green


Alex White MCDBA MCSE said:
Can you change the line to:-

strSQL = "Select * from Daily_Report Where Origin Like " & chr(34) &
me.txtOrigin.value & "1*" & chr(34)

the reason for this is I think the error is in the speech marks the
chr(34)
is ascii for " so it enters them into the line without any problems.
Does
what I am sugesting make sense?

your strings have to be enclosed within speech marks for the select
statement to work.

Good luck..

--
Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk

Hi Alex,

Sorry...
there is an error on the line same line again...
"compile error: syntax error"
I have checked the table and yes, the Daily_Report has a field named
Origin
and I have changed the text box on the form to txtOrigin
Sorry for the troubles

Best Regards
Green

:

Yep small typo

strSQL = "Select * from Daily_Report where Origin Like '" &
me.txtOrigin.value & "*'"

the above is correct if,

you have a field called Origin in a table called Daily_Report
you have a textbox on the form called txtOrigin

the typo was the table name

--
Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk

Hi Alex,

Really sorry to trouble you again...
but after i put it in to the properties-after update field, there
is
error
in this line:
strSQL = "Select * from tblDaily_Report where Origin Like '" &
me.txtOrigin.value & "*'"

I have listened to your advice and changed the table named to:
"Daily_Report".
Did i put in the correct field?
Sorry i have totally no knowlegde on coding...

Best Regards
Green

:

Hi,

You are using the phrase subform, do you really mean a form
embeded
within
another form, or just called from the Origin_search form?

if it is a sub form then the following should work


** Start **

dim strSQL as string

strSQL = "Select * from [tblDaily Report] where Origin Like
'" &
me.txtOrigin.value & "*'"

Form_Origin_search.Daily_Report_Subform.Form.RecordSource =
strSQL

Form_Origin_search.Daily_Report_Subform.Requery

** End **

For the above to work it must be called from the Origin_search
form.


Do you need to edit this data?, because if you don't then using a
listbox
on
the main form maybe the best answer to your specific problem.

--
Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk
 
G

Guest

Hi Alex,

I just found this code in some other forum that allow me to filter the
records successfully!

Private Sub txtOrigin_AfterUpdate()
With Me.[Daily_Report_subform].Form
If .Dirty Then
.Dirty = False
End If
If IsNull(Me.txtOrigin) Then
.FilterOn = False 'Nothing entered: show all records.
Else
.Filter = "Origin Like ""*" & Me.txtOrigin & "*"""
.FilterOn = True
End If
End With
End Sub

However, is there any idea only do i add on if i have more criteria added?
Like field: Destination, and etc.
By the way do you have any idea on how to prevent user from editing the
subform? Like locked it? I try going to the properties and locked, but i was
then unable to filter...

Regards
Green
 
A

Alex White MCDBA MCSE

Hi,

..AllowEdit

Form_Origin_search.Daily_Report_Subform.Form.AllowEdits = False

Should do the trick.....

Will you ever need to edit anything in the subform?
--
Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk

'green' said:
Hi Alex,

I just found this code in some other forum that allow me to filter the
records successfully!

Private Sub txtOrigin_AfterUpdate()
With Me.[Daily_Report_subform].Form
If .Dirty Then
.Dirty = False
End If
If IsNull(Me.txtOrigin) Then
.FilterOn = False 'Nothing entered: show all records.
Else
.Filter = "Origin Like ""*" & Me.txtOrigin & "*"""
.FilterOn = True
End If
End With
End Sub

However, is there any idea only do i add on if i have more criteria added?
Like field: Destination, and etc.
By the way do you have any idea on how to prevent user from editing the
subform? Like locked it? I try going to the properties and locked, but i
was
then unable to filter...

Regards
Green

Alex White MCDBA MCSE said:
Hi,

couple of things,

strSQL = "Select * from Daily_Report Where Origin Like " & chr(34) &
me.txtOrigin.value & "*" & chr(34)


you did remove the 1 before the last * in the line above?

and even though your sub form is called

Daily_Report_SubForm

if you type

Form_Origin_search.Daily_Report_Subform.Form


when you put the . on the end of that line do you get the context list
come
up, because if you don't then it sounds like the subform has been renamed
once embeded on the main form, to check this right mouse click on the
small
black frame around the subform when in design mode to get the properties
of
the subform.


--
Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk
 
G

Guest

Hi Alex,

No i will not be editing in the form itself. it is just for filter and
viewing.
as for this: Form_Origin_search.Daily_Report_Subform.Form.AllowEdits = False
where should i put it???
Sorry for teaching a dumb!

Regards
Green


Alex White MCDBA MCSE said:
Hi,

..AllowEdit

Form_Origin_search.Daily_Report_Subform.Form.AllowEdits = False

Should do the trick.....

Will you ever need to edit anything in the subform?
--
Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk

'green' said:
Hi Alex,

I just found this code in some other forum that allow me to filter the
records successfully!

Private Sub txtOrigin_AfterUpdate()
With Me.[Daily_Report_subform].Form
If .Dirty Then
.Dirty = False
End If
If IsNull(Me.txtOrigin) Then
.FilterOn = False 'Nothing entered: show all records.
Else
.Filter = "Origin Like ""*" & Me.txtOrigin & "*"""
.FilterOn = True
End If
End With
End Sub

However, is there any idea only do i add on if i have more criteria added?
Like field: Destination, and etc.
By the way do you have any idea on how to prevent user from editing the
subform? Like locked it? I try going to the properties and locked, but i
was
then unable to filter...

Regards
Green

Alex White MCDBA MCSE said:
Hi,

couple of things,

strSQL = "Select * from Daily_Report Where Origin Like " & chr(34) &
me.txtOrigin.value & "*" & chr(34)


you did remove the 1 before the last * in the line above?

and even though your sub form is called

Daily_Report_SubForm

if you type

Form_Origin_search.Daily_Report_Subform.Form


when you put the . on the end of that line do you get the context list
come
up, because if you don't then it sounds like the subform has been renamed
once embeded on the main form, to check this right mouse click on the
small
black frame around the subform when in design mode to get the properties
of
the subform.


--
Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk

Hi Alex,

I manage to remove the error... but there is an run time error '424'
Oject Required.

What is this???
Pls advice

Thanks
Green

:

Hi Alex,

it is still unsuccessful... i don't think that is the problem...
is there any other way to change the "me." ? I'm thinking whether it
is
the
problem.... but i may be wrong...

Best Regards
Green
 
A

Alex White MCDBA MCSE

Hey, sorry for what, I personally get great pleasure out of helping people
and training people very rewarding, glad I can help, it helps break my
working day up into manageable chunks.

because you are never editing the form, couple of things come to mind first

if you design view the subform on it's own, and go to the properties of the
form, (right mouse click on the square dot, top left when in design view,
goto properties

there is a few settings there

..AllowEdits
..AllowDeletions
..AllowAdditions


you can set these at a form level = No double click on the word yes and it
will rotate between yes and no, save the form, see if that works,

if that does not do what you want you can lock each control on the form by
setting the properties of the textboxes to

enabled = no
locked = yes

makes them readonly


e.g.







--
Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk

'green' said:
Hi Alex,

No i will not be editing in the form itself. it is just for filter and
viewing.
as for this: Form_Origin_search.Daily_Report_Subform.Form.AllowEdits =
False
where should i put it???
Sorry for teaching a dumb!

Regards
Green


Alex White MCDBA MCSE said:
Hi,

..AllowEdit

Form_Origin_search.Daily_Report_Subform.Form.AllowEdits = False

Should do the trick.....

Will you ever need to edit anything in the subform?
--
Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk

'green' said:
Hi Alex,

I just found this code in some other forum that allow me to filter the
records successfully!

Private Sub txtOrigin_AfterUpdate()
With Me.[Daily_Report_subform].Form
If .Dirty Then
.Dirty = False
End If
If IsNull(Me.txtOrigin) Then
.FilterOn = False 'Nothing entered: show all records.
Else
.Filter = "Origin Like ""*" & Me.txtOrigin & "*"""
.FilterOn = True
End If
End With
End Sub

However, is there any idea only do i add on if i have more criteria
added?
Like field: Destination, and etc.
By the way do you have any idea on how to prevent user from editing the
subform? Like locked it? I try going to the properties and locked, but
i
was
then unable to filter...

Regards
Green

:

Hi,

couple of things,

strSQL = "Select * from Daily_Report Where Origin Like " & chr(34) &
me.txtOrigin.value & "*" & chr(34)


you did remove the 1 before the last * in the line above?

and even though your sub form is called

Daily_Report_SubForm

if you type

Form_Origin_search.Daily_Report_Subform.Form


when you put the . on the end of that line do you get the context list
come
up, because if you don't then it sounds like the subform has been
renamed
once embeded on the main form, to check this right mouse click on the
small
black frame around the subform when in design mode to get the
properties
of
the subform.


--
Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk

Hi Alex,

I manage to remove the error... but there is an run time error '424'
Oject Required.

What is this???
Pls advice

Thanks
Green

:

Hi Alex,

it is still unsuccessful... i don't think that is the problem...
is there any other way to change the "me." ? I'm thinking whether
it
is
the
problem.... but i may be wrong...

Best Regards
Green
 
G

Guest

Hi Alex,

Really thanks for it! :)
It works!
So how can i edit the code that i previously posted with more criteria added
in?

Thanks
Green

Alex White MCDBA MCSE said:
Hey, sorry for what, I personally get great pleasure out of helping people
and training people very rewarding, glad I can help, it helps break my
working day up into manageable chunks.

because you are never editing the form, couple of things come to mind first

if you design view the subform on it's own, and go to the properties of the
form, (right mouse click on the square dot, top left when in design view,
goto properties

there is a few settings there

..AllowEdits
..AllowDeletions
..AllowAdditions


you can set these at a form level = No double click on the word yes and it
will rotate between yes and no, save the form, see if that works,

if that does not do what you want you can lock each control on the form by
setting the properties of the textboxes to

enabled = no
locked = yes

makes them readonly


e.g.







--
Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk

'green' said:
Hi Alex,

No i will not be editing in the form itself. it is just for filter and
viewing.
as for this: Form_Origin_search.Daily_Report_Subform.Form.AllowEdits =
False
where should i put it???
Sorry for teaching a dumb!

Regards
Green


Alex White MCDBA MCSE said:
Hi,

..AllowEdit

Form_Origin_search.Daily_Report_Subform.Form.AllowEdits = False

Should do the trick.....

Will you ever need to edit anything in the subform?
--
Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk

Hi Alex,

I just found this code in some other forum that allow me to filter the
records successfully!

Private Sub txtOrigin_AfterUpdate()
With Me.[Daily_Report_subform].Form
If .Dirty Then
.Dirty = False
End If
If IsNull(Me.txtOrigin) Then
.FilterOn = False 'Nothing entered: show all records.
Else
.Filter = "Origin Like ""*" & Me.txtOrigin & "*"""
.FilterOn = True
End If
End With
End Sub

However, is there any idea only do i add on if i have more criteria
added?
Like field: Destination, and etc.
By the way do you have any idea on how to prevent user from editing the
subform? Like locked it? I try going to the properties and locked, but
i
was
then unable to filter...

Regards
Green

:

Hi,

couple of things,

strSQL = "Select * from Daily_Report Where Origin Like " & chr(34) &
me.txtOrigin.value & "*" & chr(34)


you did remove the 1 before the last * in the line above?

and even though your sub form is called

Daily_Report_SubForm

if you type

Form_Origin_search.Daily_Report_Subform.Form


when you put the . on the end of that line do you get the context list
come
up, because if you don't then it sounds like the subform has been
renamed
once embeded on the main form, to check this right mouse click on the
small
black frame around the subform when in design mode to get the
properties
of
the subform.


--
Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk

Hi Alex,

I manage to remove the error... but there is an run time error '424'
Oject Required.

What is this???
Pls advice

Thanks
Green

:

Hi Alex,

it is still unsuccessful... i don't think that is the problem...
is there any other way to change the "me." ? I'm thinking whether
it
is
the
problem.... but i may be wrong...

Best Regards
Green
 
A

Alex White MCDBA MCSE

Hi,

You will need to build the filter into a string, the idea here is simple,
check the values on the form if there is anything in the boxes then build
them into the strFilter variable, then at the end pass the variable as the
filter. For more than one entry on the filter line 'AND' must be used to
break them up, watch out for anything other than strings because they need
to be formatted differently. With the idea below you can make you searches
much more defined.

Dim strFilter as string
Dim bolAnd As Boolean
bolAnd = False
strFilter = ""
If Len(Me.Title.Value) > 0 Then
If bolAnd Then
strFilter = strFilter & " and "
End If
strFilter = strFilter & " Title Like '*" & Me.Title.Value & "*'"
bolAnd = True
end if
If Len(Me.First_Name.Value) > 0 Then
If bolAnd Then
strFilter = strFilter & " and "
End If
strFilter = strFilter & " First_Name Like '*" & Me.First_Name.Value
& "*'"
bolAnd = True
end if

.Filter = strFilter

Good Luck, post back if you need more help.


--
Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk

'green' said:
Hi Alex,

Really thanks for it! :)
It works!
So how can i edit the code that i previously posted with more criteria
added
in?

Thanks
Green

Alex White MCDBA MCSE said:
Hey, sorry for what, I personally get great pleasure out of helping
people
and training people very rewarding, glad I can help, it helps break my
working day up into manageable chunks.

because you are never editing the form, couple of things come to mind
first

if you design view the subform on it's own, and go to the properties of
the
form, (right mouse click on the square dot, top left when in design view,
goto properties

there is a few settings there

..AllowEdits
..AllowDeletions
..AllowAdditions


you can set these at a form level = No double click on the word yes and
it
will rotate between yes and no, save the form, see if that works,

if that does not do what you want you can lock each control on the form
by
setting the properties of the textboxes to

enabled = no
locked = yes

makes them readonly


e.g.







--
Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk

'green' said:
Hi Alex,

No i will not be editing in the form itself. it is just for filter and
viewing.
as for this: Form_Origin_search.Daily_Report_Subform.Form.AllowEdits =
False
where should i put it???
Sorry for teaching a dumb!

Regards
Green


:

Hi,

..AllowEdit

Form_Origin_search.Daily_Report_Subform.Form.AllowEdits = False

Should do the trick.....

Will you ever need to edit anything in the subform?
--
Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk

Hi Alex,

I just found this code in some other forum that allow me to filter
the
records successfully!

Private Sub txtOrigin_AfterUpdate()
With Me.[Daily_Report_subform].Form
If .Dirty Then
.Dirty = False
End If
If IsNull(Me.txtOrigin) Then
.FilterOn = False 'Nothing entered: show all records.
Else
.Filter = "Origin Like ""*" & Me.txtOrigin & "*"""
.FilterOn = True
End If
End With
End Sub

However, is there any idea only do i add on if i have more criteria
added?
Like field: Destination, and etc.
By the way do you have any idea on how to prevent user from editing
the
subform? Like locked it? I try going to the properties and locked,
but
i
was
then unable to filter...

Regards
Green

:

Hi,

couple of things,

strSQL = "Select * from Daily_Report Where Origin Like " & chr(34)
&
me.txtOrigin.value & "*" & chr(34)


you did remove the 1 before the last * in the line above?

and even though your sub form is called

Daily_Report_SubForm

if you type

Form_Origin_search.Daily_Report_Subform.Form


when you put the . on the end of that line do you get the context
list
come
up, because if you don't then it sounds like the subform has been
renamed
once embeded on the main form, to check this right mouse click on
the
small
black frame around the subform when in design mode to get the
properties
of
the subform.


--
Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk

Hi Alex,

I manage to remove the error... but there is an run time error
'424'
Oject Required.

What is this???
Pls advice

Thanks
Green

:

Hi Alex,

it is still unsuccessful... i don't think that is the problem...
is there any other way to change the "me." ? I'm thinking
whether
it
is
the
problem.... but i may be wrong...

Best Regards
Green
 
G

Guest

Hi Alex,

I don't quite get your idea. Yes, The other criteria is of different format
which are date and number.
As for the code, where should i put it in? Under the subform property or
those unbounded fields in the main form?
By the way, i see the code you did, i don't see any form to look into.. so
will it filter and show the records in the subform when i entered in the main
form?
Pls advice, and let me know if i see it wrongly.

Regards
Green


Alex White MCDBA MCSE said:
Hi,

You will need to build the filter into a string, the idea here is simple,
check the values on the form if there is anything in the boxes then build
them into the strFilter variable, then at the end pass the variable as the
filter. For more than one entry on the filter line 'AND' must be used to
break them up, watch out for anything other than strings because they need
to be formatted differently. With the idea below you can make you searches
much more defined.

Dim strFilter as string
Dim bolAnd As Boolean
bolAnd = False
strFilter = ""
If Len(Me.Title.Value) > 0 Then
If bolAnd Then
strFilter = strFilter & " and "
End If
strFilter = strFilter & " Title Like '*" & Me.Title.Value & "*'"
bolAnd = True
end if
If Len(Me.First_Name.Value) > 0 Then
If bolAnd Then
strFilter = strFilter & " and "
End If
strFilter = strFilter & " First_Name Like '*" & Me.First_Name.Value
& "*'"
bolAnd = True
end if

.Filter = strFilter

Good Luck, post back if you need more help.


--
Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk

'green' said:
Hi Alex,

Really thanks for it! :)
It works!
So how can i edit the code that i previously posted with more criteria
added
in?

Thanks
Green

Alex White MCDBA MCSE said:
Hey, sorry for what, I personally get great pleasure out of helping
people
and training people very rewarding, glad I can help, it helps break my
working day up into manageable chunks.

because you are never editing the form, couple of things come to mind
first

if you design view the subform on it's own, and go to the properties of
the
form, (right mouse click on the square dot, top left when in design view,
goto properties

there is a few settings there

..AllowEdits
..AllowDeletions
..AllowAdditions


you can set these at a form level = No double click on the word yes and
it
will rotate between yes and no, save the form, see if that works,

if that does not do what you want you can lock each control on the form
by
setting the properties of the textboxes to

enabled = no
locked = yes

makes them readonly


e.g.







--
Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk

Hi Alex,

No i will not be editing in the form itself. it is just for filter and
viewing.
as for this: Form_Origin_search.Daily_Report_Subform.Form.AllowEdits =
False
where should i put it???
Sorry for teaching a dumb!

Regards
Green


:

Hi,

..AllowEdit

Form_Origin_search.Daily_Report_Subform.Form.AllowEdits = False

Should do the trick.....

Will you ever need to edit anything in the subform?
--
Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk

Hi Alex,

I just found this code in some other forum that allow me to filter
the
records successfully!

Private Sub txtOrigin_AfterUpdate()
With Me.[Daily_Report_subform].Form
If .Dirty Then
.Dirty = False
End If
If IsNull(Me.txtOrigin) Then
.FilterOn = False 'Nothing entered: show all records.
Else
.Filter = "Origin Like ""*" & Me.txtOrigin & "*"""
.FilterOn = True
End If
End With
End Sub

However, is there any idea only do i add on if i have more criteria
added?
Like field: Destination, and etc.
By the way do you have any idea on how to prevent user from editing
the
subform? Like locked it? I try going to the properties and locked,
but
i
was
then unable to filter...

Regards
Green

:

Hi,

couple of things,

strSQL = "Select * from Daily_Report Where Origin Like " & chr(34)
&
me.txtOrigin.value & "*" & chr(34)


you did remove the 1 before the last * in the line above?

and even though your sub form is called

Daily_Report_SubForm

if you type

Form_Origin_search.Daily_Report_Subform.Form


when you put the . on the end of that line do you get the context
list
come
up, because if you don't then it sounds like the subform has been
renamed
once embeded on the main form, to check this right mouse click on
the
small
black frame around the subform when in design mode to get the
properties
of
the subform.


--
Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk

Hi Alex,

I manage to remove the error... but there is an run time error
'424'
Oject Required.

What is this???
Pls advice

Thanks
Green

:

Hi Alex,

it is still unsuccessful... i don't think that is the problem...
is there any other way to change the "me." ? I'm thinking
whether
it
is
the
problem.... but i may be wrong...

Best Regards
Green
 
A

Alex White MCDBA MCSE

Hi,

yep dates need to be wrapped in #, always format for US date format (I don't
know where you are located)

numbers have no " round them

I guess you have a 'Search' button on the form, put the code in the click
event for the button.

Dim strFilter as string
Dim bolAnd As Boolean
bolAnd = False
strFilter = ""
If Len(Me.Title.Value) > 0 Then
If bolAnd Then
strFilter = strFilter & " and "
End If
strFilter = strFilter & " Title Like '*" & Me.Title.Value & "*'"
bolAnd = True
end if
If Len(Me.First_Name.Value) > 0 Then
If bolAnd Then
strFilter = strFilter & " and "
End If
strFilter = strFilter & " First_Name Like '*" & Me.First_Name.Value
& "*'"
bolAnd = True
end if

With Me.[Daily_Report_subform].Form
If .Dirty Then
.Dirty = False
End If
If strFilter = "" Then
.FilterOn = False 'Nothing entered: show all records.
Else
.Filter = strFilter
.FilterOn = True
End If
End With

change the textbox names to suit your needs

--
Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk

'green' said:
Hi Alex,

I don't quite get your idea. Yes, The other criteria is of different
format
which are date and number.
As for the code, where should i put it in? Under the subform property or
those unbounded fields in the main form?
By the way, i see the code you did, i don't see any form to look into.. so
will it filter and show the records in the subform when i entered in the
main
form?
Pls advice, and let me know if i see it wrongly.

Regards
Green


Alex White MCDBA MCSE said:
Hi,

You will need to build the filter into a string, the idea here is simple,
check the values on the form if there is anything in the boxes then build
them into the strFilter variable, then at the end pass the variable as
the
filter. For more than one entry on the filter line 'AND' must be used to
break them up, watch out for anything other than strings because they
need
to be formatted differently. With the idea below you can make you
searches
much more defined.

Dim strFilter as string
Dim bolAnd As Boolean
bolAnd = False
strFilter = ""
If Len(Me.Title.Value) > 0 Then
If bolAnd Then
strFilter = strFilter & " and "
End If
strFilter = strFilter & " Title Like '*" & Me.Title.Value & "*'"
bolAnd = True
end if
If Len(Me.First_Name.Value) > 0 Then
If bolAnd Then
strFilter = strFilter & " and "
End If
strFilter = strFilter & " First_Name Like '*" &
Me.First_Name.Value
& "*'"
bolAnd = True
end if

.Filter = strFilter

Good Luck, post back if you need more help.


--
Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk

'green' said:
Hi Alex,

Really thanks for it! :)
It works!
So how can i edit the code that i previously posted with more criteria
added
in?

Thanks
Green

:

Hey, sorry for what, I personally get great pleasure out of helping
people
and training people very rewarding, glad I can help, it helps break my
working day up into manageable chunks.

because you are never editing the form, couple of things come to mind
first

if you design view the subform on it's own, and go to the properties
of
the
form, (right mouse click on the square dot, top left when in design
view,
goto properties

there is a few settings there

..AllowEdits
..AllowDeletions
..AllowAdditions


you can set these at a form level = No double click on the word yes
and
it
will rotate between yes and no, save the form, see if that works,

if that does not do what you want you can lock each control on the
form
by
setting the properties of the textboxes to

enabled = no
locked = yes

makes them readonly


e.g.







--
Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk

Hi Alex,

No i will not be editing in the form itself. it is just for filter
and
viewing.
as for this: Form_Origin_search.Daily_Report_Subform.Form.AllowEdits
=
False
where should i put it???
Sorry for teaching a dumb!

Regards
Green


:

Hi,

..AllowEdit

Form_Origin_search.Daily_Report_Subform.Form.AllowEdits = False

Should do the trick.....

Will you ever need to edit anything in the subform?
--
Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk

Hi Alex,

I just found this code in some other forum that allow me to
filter
the
records successfully!

Private Sub txtOrigin_AfterUpdate()
With Me.[Daily_Report_subform].Form
If .Dirty Then
.Dirty = False
End If
If IsNull(Me.txtOrigin) Then
.FilterOn = False 'Nothing entered: show all
records.
Else
.Filter = "Origin Like ""*" & Me.txtOrigin & "*"""
.FilterOn = True
End If
End With
End Sub

However, is there any idea only do i add on if i have more
criteria
added?
Like field: Destination, and etc.
By the way do you have any idea on how to prevent user from
editing
the
subform? Like locked it? I try going to the properties and
locked,
but
i
was
then unable to filter...

Regards
Green

:

Hi,

couple of things,

strSQL = "Select * from Daily_Report Where Origin Like " &
chr(34)
&
me.txtOrigin.value & "*" & chr(34)


you did remove the 1 before the last * in the line above?

and even though your sub form is called

Daily_Report_SubForm

if you type

Form_Origin_search.Daily_Report_Subform.Form


when you put the . on the end of that line do you get the
context
list
come
up, because if you don't then it sounds like the subform has
been
renamed
once embeded on the main form, to check this right mouse click
on
the
small
black frame around the subform when in design mode to get the
properties
of
the subform.


--
Regards

Alex White MCDBA MCSE
http://www.intralan.co.uk

Hi Alex,

I manage to remove the error... but there is an run time error
'424'
Oject Required.

What is this???
Pls advice

Thanks
Green

:

Hi Alex,

it is still unsuccessful... i don't think that is the
problem...
is there any other way to change the "me." ? I'm thinking
whether
it
is
the
problem.... but i may be wrong...

Best Regards
Green
 

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