D
DoveArrow
Let me try to explain exactly what I'm trying to do and see if anyone
can help me with this.
I have a table in my database, called Skills Table. It's a little
complicated to explain what 'skills' are, but suffice it to say each
skill in my table has a record source. I therefore created a second
table, called Source Table, listing the names of the record sources
that each skill could come from. I then linked this table to the
Skills Table by Source ID.
What I want to do now is create a form with a Multi Select List box,
where I can select which sources I want to use for skills, and have
that information be used as the criteria for a parameter query. I went
to the Microsoft Help and Support website (http://
support.microsoft.com/kb/135546) to see if they had any information
about how to do this, and they had two options listed.
Now I don't really understand how either of these options are supposed
to work (Example: How is the database supposed to know which query I
want to use these criteria for?). However, I could at least understand
some of what the first option was saying, so I decided to try creating
my form based on its method. Here's what I did.
1) I created a form, using the Skills Table as my Record Source.
2) I dragged the Skill ID and the Skill Name fields to the detail
section of my form (I don't know if that's what I was supposed to do,
but those sounded like the equivalent fields described on the
Microsoft Help & Support website. Later, I also tried dragging the
Source ID to the form as well, just to see if that made any
difference. It didn't.)
3) I created an unbound List Box that uses the Skills Table as the row
source, made all the appropriate adjustments, and entitled it
"SkillSourceList."
4) I then tried rewriting the code that Microsoft listed in the
following manner.
Option Compare Database
OptionExplicit
Private Sub Command7_Click()
Dim Criteria As String
Dim i As Variant
' Build criteria string from selected items in list box.
Criteria = ""
For Each i In Me![SkillSourceList].ItemsSelected
If Criteria <> "" Then
Criteria = Criteria & " OR "
End If
Criteria = Criteria & "[Source ID]='" _
& Me![SkillSourceList].ItemData(i) & "'"
Next i
' Filter the form using selected items in the list box.
Me.Filter = Criteria
Me.FilterOn = True
End Sub
5) I then went into form view and clicked my Command button and got
this error message:
"The expression On Click you entered as the event property setting
produced the following error:
Invalid outside procedure.
*The expression may not result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event, or
macro."
So what did I do wrong?
can help me with this.
I have a table in my database, called Skills Table. It's a little
complicated to explain what 'skills' are, but suffice it to say each
skill in my table has a record source. I therefore created a second
table, called Source Table, listing the names of the record sources
that each skill could come from. I then linked this table to the
Skills Table by Source ID.
What I want to do now is create a form with a Multi Select List box,
where I can select which sources I want to use for skills, and have
that information be used as the criteria for a parameter query. I went
to the Microsoft Help and Support website (http://
support.microsoft.com/kb/135546) to see if they had any information
about how to do this, and they had two options listed.
Now I don't really understand how either of these options are supposed
to work (Example: How is the database supposed to know which query I
want to use these criteria for?). However, I could at least understand
some of what the first option was saying, so I decided to try creating
my form based on its method. Here's what I did.
1) I created a form, using the Skills Table as my Record Source.
2) I dragged the Skill ID and the Skill Name fields to the detail
section of my form (I don't know if that's what I was supposed to do,
but those sounded like the equivalent fields described on the
Microsoft Help & Support website. Later, I also tried dragging the
Source ID to the form as well, just to see if that made any
difference. It didn't.)
3) I created an unbound List Box that uses the Skills Table as the row
source, made all the appropriate adjustments, and entitled it
"SkillSourceList."
4) I then tried rewriting the code that Microsoft listed in the
following manner.
Option Compare Database
OptionExplicit
Private Sub Command7_Click()
Dim Criteria As String
Dim i As Variant
' Build criteria string from selected items in list box.
Criteria = ""
For Each i In Me![SkillSourceList].ItemsSelected
If Criteria <> "" Then
Criteria = Criteria & " OR "
End If
Criteria = Criteria & "[Source ID]='" _
& Me![SkillSourceList].ItemData(i) & "'"
Next i
' Filter the form using selected items in the list box.
Me.Filter = Criteria
Me.FilterOn = True
End Sub
5) I then went into form view and clicked my Command button and got
this error message:
"The expression On Click you entered as the event property setting
produced the following error:
Invalid outside procedure.
*The expression may not result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event, or
macro."
So what did I do wrong?