S
strive4peace
Hi Jessica,
" I am afraid I'm not sure how to know if I have the subform
synchronized with LinkMasterFields and LinkChildFields. "
Read Access Basics ... it is only 100 pages and has lots of screen shots
<smile>
You will find the answer ... LinkMasterFields and LinkChildFields are
properties of a subform/subreport control
~~~
this SQL statement does not have any criteria:
SELECT DISTINCT [SNM Type]FROM [SNM Data]ORDER BY [SNM Type];
~~~
" As far as using "no criteria" to show all the records, I'm not sure
how to do that."
me.FilterOn = false
when you change a Filter, you need to requery after you change it...
me.Requery
Warm Regards,
Crystal
remote programming and training
Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace
*
have an awesome day
*
" I am afraid I'm not sure how to know if I have the subform
synchronized with LinkMasterFields and LinkChildFields. "
Read Access Basics ... it is only 100 pages and has lots of screen shots
<smile>
You will find the answer ... LinkMasterFields and LinkChildFields are
properties of a subform/subreport control
~~~
this SQL statement does not have any criteria:
SELECT DISTINCT [SNM Type]FROM [SNM Data]ORDER BY [SNM Type];
~~~
" As far as using "no criteria" to show all the records, I'm not sure
how to do that."
me.FilterOn = false
when you change a Filter, you need to requery after you change it...
me.Requery
Warm Regards,
Crystal
remote programming and training
Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace
*
have an awesome day
*
Crystal,
Thank you so much for looking at my code! I am afraid I'm not sure how to
know if I have the subform synchronized with LinkMasterFields and
LinkChildFields. Could you explain that process/what those are? I think I
am using a query to get the info from the table onto the form. my combo
boxes have row source type set to table/query and the row sources have this
in them: (the other combo box has the same but with a different field)
SELECT DISTINCT [SNM Type]FROM [SNM Data]ORDER BY [SNM Type];
So my main form has two combo boxes, combo22 and combo24. It pulls up the
SNM TYPE and ICA (both fields in my table) from my "SNM Type" table. My main
form also have "Go" and "Reset" buttons which are the Command44 and
Command43.
My subform is just a subform I made in the wizard, and it took the field
names from my table and made them text boxes with labels. When I am in "form
view" it shows up as a table, not individual text boxes (This is what I want).
As far as using "no criteria" to show all the records, I'm not sure how to
do that. What would that change when I used my form?
Is there anything else I can tell you to help you? Thank you so much!
Jessica
strive4peace said:Hi Jessica,
your code only sets a filter on the main form ... it does nothing with
the subform.
1. Do you have the subform synchronized with LinkMasterFields and
LinkChildFields?
2. Are you using a query for the RecordSource of subform that gets
criteria from the main form? (if so, this is not the best way -- #1 is)
Can you explain what type of information is in your main form and your
subform?
~~~
instead of this:
If lngLen <= 0 Then
MsgBox "No criteria", vbInformation, "Nothing to do."
you might want to use no criteria to show all the records
~~~
Command44 :
before you write code for a control, you should give it a logical Name
like --> cmdApplyFilter
for more information, read about Properties and Methods here:
Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace
Warm Regards,
Crystal
remote programming and training
*
have an awesome day
*
Crystal,
You seem to really know your stuff with regards to filtering and forms, so
I'm hoping you can help me out.
I have a form with two combo boxes that pull information from their
respective fields in a table. I have set them up with a "go" command button
to filter the info in the table based on what I select in the combo box, and
it shows up in a subform. The problem I'm having is that if I exit form view
and go to design view, or close the file and re-open it, the command button
stops working unless I right click the subform (in form veiw) select "filter
by form" and then "apply filter/sort". After doing this the "go" Command
button works perfectly unless I exit out of the form view. I also have a
"reset" command button that, when I have the "go" button working but the
above steps, only clears the combo boxes, not the results in the subform.
Before I figured out that I had to select "filter by form" and "apply
filter/sort" my form worked only if I selected what I wanted in form view,
clicked into design view, and then when I clicked back into form view the
results had pulled up into the subform. My reset button also cleared the
whole subform. The code is below where command44 s the go button and
command43 is the reset button. Combo22 and Combo24 are my two combo boxes.
Option Compare Database
Option Explicit
Private Sub Combo22_AfterUpdate()
End Sub
Private Sub Command44_Click()
Dim strWhere As String 'The criteria string.
Dim lngLen As Long
If Not IsNull(Me.Combo22) Then
strWhere = strWhere & "([SNM TYPE] = """ & Me.Combo22 & """) AND "
End If
If Not IsNull(Me.Combo24) Then
strWhere = strWhere & "([ICA] = """ & Me.Combo24 & """) AND "
End If
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "No criteria", vbInformation, "Nothing to do."
Else
strWhere = Left$(strWhere, lngLen)
Debug.Print strWhere
Me.Filter = strWhere
Me.FilterOn = True
End If
End Sub
Private Sub Command43_Click()
'Purpose: Clear all the search boxes in the Form Header, and show all
records again.
Dim ctl As Control
'Clear all the controls in the Form Header section.
For Each ctl In Me.Section(acDetail).Controls
Select Case ctl.ControlType
Case acComboBox
ctl.Value = Null
End Select
Next
'Remove the form's filter.
Me.FilterOn = False
End Sub
The Immediate line after my Debug.print shows like it should be working:
([SNM TYPE] = "IRM-C") AND ([ICA] = "Reactor Core")
Can you help me?
:
Hi Dave,
oops, sorry I put an extra quote mark in (was distracted doing something
else at the same time)...
take out the extra space on either side of *
remove extra quote on end -- you should only have ONE double quote on
the end because you will be concatenating your search string
(Me.cboquicksearch4)
this is not right:
....Like """ * "" & ...
do this:
....Like ""*" & ...
"" -- embed one quote mark
* -- wildcard
" -- end string
what you will end up with, if your combo value is '123 Main street' is this:
mFilter = "[defendant addressm] Like ""*123 Main street*"""
Filter: [defendant addressm] Like "*123 Main street*"
'~~~~~~~~~ Compile ~~~~~~~~~
Whenever you change code or references, your should always compile
before executing.
from the menu in a VBE (module) window: Debug, Compile
fix any errors on the yellow highlighted lines
keep compiling until nothing happens (this is good!)
~~
if you run code without compiling it, you risk corrupting your database
Warm Regards,
Crystal
Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace
*
have an awesome day
*
Dave wrote:
this is the portion of code that is not working...
mFilter = "[defendant addressm] Like """ * "" _
& Me.cboquicksearch4 & "*"""
:
Thank you so much.... it makes sense and I appreciate your help. However,
when I execute I get a 'run-time error 13, type mismatch. Any idea why?
:
Hi Dave,
no extra spaces in the mask
use the word 'Like' instead of equal sign if you have a mask
if you use double quotes to surround the mask, you must use TWO of them
since you are using double quotes to delimit your filter
put this in the [Event Procedure] of the AfterUpdate event of
cboquicksearch
'~~~~~~~~~~~~~
dim mFilter as string
if isnull(me.cboquicksearch) then
'show all records
me.FilterOn = false
else
mFilter = "[defendant addressm] Like """*" _
& Me.cboquicksearch & "*"""
me.filter = mFilter
me.FilterOn = true
end if
me.requery
'~~~~~~~~~~~~~
if your data will not contain a single quote, you can also do this:
mFilter = "[defendant addressm] Like "'*" _
& Me.cboquicksearch & "*'"
WHERE
'defendant addressm' is the name of your field and its data type is text
BUT ... if you are using a combobox, I assume you are giving the user a
list of addresses to pick from. If they choose a complete address, you
do not need to use LIKE
mFilter = "[defendant addressm] = "'" _
& Me.cboquicksearch & "'"
Warm Regards,
Crystal
Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace
*
have an awesome day
*
Dave wrote:
I didn't start the string but my question is the same. I haven't found the
answer and can't locate a source. Hopefully someone here can help. I'm
using an unbound combo box on a form. I want the user to type in a partial
address and have the combo box filter only those records that have what the
user typed in.
My code is wrong.
Me.Filter = "[defendant addressm]= "" * " & Me.cboquicksearch & " * """
Me.FilterOn = True
I can't get the filter to work. "the text you entered isn't an item on the
list" is the error message I get.
Can someone help me out....?
Thanks in advance.
Dave