Help me Crack the Code

G

Guest

Hello,
Hoping someone can help. I have imported a module from another database
which is executed from a query with the following sql statement:

SELECT TblComp.*
FROM TblComp
WHERE
(((IsSelectedVar("frmMultiselectListDemo","lboSpecificCompetency","SpecificCompetency"))=-1));

I think there might be something wrong with following code because I get an
error saying that it does not recrognise the form name. The problem in the
code I think is from the 15th line:

Function IsSelectedVar( _
strFormName As String, _
strListBoxName As String, _
varValue As Variant) _
As Boolean
'strFormName is the name of the form
'strListBoxName is the name of the listbox
'varValue is the field to check against the listbox
Dim lbo As ListBox
Dim item As Variant
If IsNumeric(varValue) Then
varValue = Trim(Str(varValue))
End If
Set lbo = Forms(strFormName)(strListBoxName)
For Each item In lbo.ItemsSelected
If lbo.ItemData(item) = varValue Then
IsSelectedVar = True
Exit Function
End If
Next
End Function

I'd really love some help understanding what the above code means from the
15th line onwards as that is what is highlighted in the error when you click
on the debug button. IN particular what does "lbo" mean exactly.

Thanks so much!
Angeline
Sydney
 
D

Duane Hookom

The code looks familiar.

The third argument in the function must be a field name from tblComp. You
are sending in a text value. It may be that you only need to change the
"SpecificCompetency" to [SpecificCompetency].

Do you have a form open named "frmMultiselectListDemo" and does this form
have a multi-select list box named "lboSpecificCompetency"?
 
G

Guest

I'm terribly sorry, I am pretty new to this and also not sure who is
answering from what country and what the timezones are (I'm in AUS). I was
trying to get this little problem sorted out in a day and thought if I
understood the code it might help. I got worried about the hours ticking by
and was trying to deliver something tomorrow but I'm kidding myself .

Thanks and I will use the cross-posting in future. I hope you havn't black
listed me.
 
G

Guest

Duane,
I could kiss you! I've been trying to work this out all day and your
suggestion about changing "" to [] was all it was. Hooray! Thanks so much for
your help with this.
You've made my night (that's really sad isn't it)
Angeline


Duane Hookom said:
The code looks familiar.

The third argument in the function must be a field name from tblComp. You
are sending in a text value. It may be that you only need to change the
"SpecificCompetency" to [SpecificCompetency].

Do you have a form open named "frmMultiselectListDemo" and does this form
have a multi-select list box named "lboSpecificCompetency"?

--
Duane Hookom
MS Access MVP
--

Angeline said:
Hello,
Hoping someone can help. I have imported a module from another database
which is executed from a query with the following sql statement:

SELECT TblComp.*
FROM TblComp
WHERE
(((IsSelectedVar("frmMultiselectListDemo","lboSpecificCompetency","SpecificCompetency"))=-1));

I think there might be something wrong with following code because I get
an
error saying that it does not recrognise the form name. The problem in the
code I think is from the 15th line:

Function IsSelectedVar( _
strFormName As String, _
strListBoxName As String, _
varValue As Variant) _
As Boolean
'strFormName is the name of the form
'strListBoxName is the name of the listbox
'varValue is the field to check against the listbox
Dim lbo As ListBox
Dim item As Variant
If IsNumeric(varValue) Then
varValue = Trim(Str(varValue))
End If
Set lbo = Forms(strFormName)(strListBoxName)
For Each item In lbo.ItemsSelected
If lbo.ItemData(item) = varValue Then
IsSelectedVar = True
Exit Function
End If
Next
End Function

I'd really love some help understanding what the above code means from the
15th line onwards as that is what is highlighted in the error when you
click
on the debug button. IN particular what does "lbo" mean exactly.

Thanks so much!
Angeline
Sydney
 
G

Guest

Duane,
I wander if you could help me progress with this. Now that I have the
multi-select list box working (thank you) how can I get the results of the
query into a static table. The goal is for the user to be able to see their
results in a report which they can print off. Is this prossible?

Thanks again for your help!
Angeline

Duane Hookom said:
The code looks familiar.

The third argument in the function must be a field name from tblComp. You
are sending in a text value. It may be that you only need to change the
"SpecificCompetency" to [SpecificCompetency].

Do you have a form open named "frmMultiselectListDemo" and does this form
have a multi-select list box named "lboSpecificCompetency"?

--
Duane Hookom
MS Access MVP
--

Angeline said:
Hello,
Hoping someone can help. I have imported a module from another database
which is executed from a query with the following sql statement:

SELECT TblComp.*
FROM TblComp
WHERE
(((IsSelectedVar("frmMultiselectListDemo","lboSpecificCompetency","SpecificCompetency"))=-1));

I think there might be something wrong with following code because I get
an
error saying that it does not recrognise the form name. The problem in the
code I think is from the 15th line:

Function IsSelectedVar( _
strFormName As String, _
strListBoxName As String, _
varValue As Variant) _
As Boolean
'strFormName is the name of the form
'strListBoxName is the name of the listbox
'varValue is the field to check against the listbox
Dim lbo As ListBox
Dim item As Variant
If IsNumeric(varValue) Then
varValue = Trim(Str(varValue))
End If
Set lbo = Forms(strFormName)(strListBoxName)
For Each item In lbo.ItemsSelected
If lbo.ItemData(item) = varValue Then
IsSelectedVar = True
Exit Function
End If
Next
End Function

I'd really love some help understanding what the above code means from the
15th line onwards as that is what is highlighted in the error when you
click
on the debug button. IN particular what does "lbo" mean exactly.

Thanks so much!
Angeline
Sydney
 
K

Keith Wilby

Angeline said:
Duane,
I could kiss you! I've been trying to work this out all day and your
suggestion about changing "" to [] was all it was. Hooray! Thanks so much
for
your help with this.
You've made my night (that's really sad isn't it)
Angeline
You know, I've been posting on Access groups for over 10 years and have
never received a response like that, you're a lucky man Duane ;-D

Keith.
www.keithwilby.com
 
B

Brian Wilson

Keith Wilby said:
Angeline said:
Duane,
I could kiss you! I've been trying to work this out all day and your
suggestion about changing "" to [] was all it was. Hooray! Thanks so much
for
your help with this.
You've made my night (that's really sad isn't it)
Angeline
You know, I've been posting on Access groups for over 10 years and have
never received a response like that, you're a lucky man Duane ;-D

Keith.
www.keithwilby.com


Try removing the photo from your website.

<just kidding>
 
D

Duane Hookom

Notice Angeline is located on the other side of the world from me. She's
fairly safe in suggesting a kiss for my effort.

--
Duane Hookom
MS Access MVP
--

Keith Wilby said:
Angeline said:
Duane,
I could kiss you! I've been trying to work this out all day and your
suggestion about changing "" to [] was all it was. Hooray! Thanks so much
for
your help with this.
You've made my night (that's really sad isn't it)
Angeline
You know, I've been posting on Access groups for over 10 years and have
never received a response like that, you're a lucky man Duane ;-D

Keith.
www.keithwilby.com
 
D

Duane Hookom

I'm not sure what you mean by "a static table".

--
Duane Hookom
MS Access MVP
--

Angeline said:
Duane,
I wander if you could help me progress with this. Now that I have the
multi-select list box working (thank you) how can I get the results of the
query into a static table. The goal is for the user to be able to see
their
results in a report which they can print off. Is this prossible?

Thanks again for your help!
Angeline

Duane Hookom said:
The code looks familiar.

The third argument in the function must be a field name from tblComp. You
are sending in a text value. It may be that you only need to change the
"SpecificCompetency" to [SpecificCompetency].

Do you have a form open named "frmMultiselectListDemo" and does this form
have a multi-select list box named "lboSpecificCompetency"?

--
Duane Hookom
MS Access MVP
--

Angeline said:
Hello,
Hoping someone can help. I have imported a module from another database
which is executed from a query with the following sql statement:

SELECT TblComp.*
FROM TblComp
WHERE
(((IsSelectedVar("frmMultiselectListDemo","lboSpecificCompetency","SpecificCompetency"))=-1));

I think there might be something wrong with following code because I
get
an
error saying that it does not recrognise the form name. The problem in
the
code I think is from the 15th line:

Function IsSelectedVar( _
strFormName As String, _
strListBoxName As String, _
varValue As Variant) _
As Boolean
'strFormName is the name of the form
'strListBoxName is the name of the listbox
'varValue is the field to check against the listbox
Dim lbo As ListBox
Dim item As Variant
If IsNumeric(varValue) Then
varValue = Trim(Str(varValue))
End If
Set lbo = Forms(strFormName)(strListBoxName)
For Each item In lbo.ItemsSelected
If lbo.ItemData(item) = varValue Then
IsSelectedVar = True
Exit Function
End If
Next
End Function

I'd really love some help understanding what the above code means from
the
15th line onwards as that is what is highlighted in the error when you
click
on the debug button. IN particular what does "lbo" mean exactly.

Thanks so much!
Angeline
Sydney
 
G

Guest

Morning Duane,
Sorry, I used my own terminology. The difficulty is that unlike other
queries, I can't tell how to actually do anything with the results. For
example: I tried to change the query to a 'make table' so that whatever the
selection is will actually be stored. The idea is for a user to be able to
see their results in the form of a report. My guess is that I should get it
into a table first? '

Thanks, really appreciate your advice
Angeline

Duane Hookom said:
I'm not sure what you mean by "a static table".

--
Duane Hookom
MS Access MVP
--

Angeline said:
Duane,
I wander if you could help me progress with this. Now that I have the
multi-select list box working (thank you) how can I get the results of the
query into a static table. The goal is for the user to be able to see
their
results in a report which they can print off. Is this prossible?

Thanks again for your help!
Angeline

Duane Hookom said:
The code looks familiar.

The third argument in the function must be a field name from tblComp. You
are sending in a text value. It may be that you only need to change the
"SpecificCompetency" to [SpecificCompetency].

Do you have a form open named "frmMultiselectListDemo" and does this form
have a multi-select list box named "lboSpecificCompetency"?

--
Duane Hookom
MS Access MVP
--

Hello,
Hoping someone can help. I have imported a module from another database
which is executed from a query with the following sql statement:

SELECT TblComp.*
FROM TblComp
WHERE
(((IsSelectedVar("frmMultiselectListDemo","lboSpecificCompetency","SpecificCompetency"))=-1));

I think there might be something wrong with following code because I
get
an
error saying that it does not recrognise the form name. The problem in
the
code I think is from the 15th line:

Function IsSelectedVar( _
strFormName As String, _
strListBoxName As String, _
varValue As Variant) _
As Boolean
'strFormName is the name of the form
'strListBoxName is the name of the listbox
'varValue is the field to check against the listbox
Dim lbo As ListBox
Dim item As Variant
If IsNumeric(varValue) Then
varValue = Trim(Str(varValue))
End If
Set lbo = Forms(strFormName)(strListBoxName)
For Each item In lbo.ItemsSelected
If lbo.ItemData(item) = varValue Then
IsSelectedVar = True
Exit Function
End If
Next
End Function

I'd really love some help understanding what the above code means from
the
15th line onwards as that is what is highlighted in the error when you
click
on the debug button. IN particular what does "lbo" mean exactly.

Thanks so much!
Angeline
Sydney
 
G

Guest

I realise that this post is getting too long and has already been
'ticked'answered so I might re-word and re-port in the Query Forum. Thanks!
Angeline

Angeline said:
Morning Duane,
Sorry, I used my own terminology. The difficulty is that unlike other
queries, I can't tell how to actually do anything with the results. For
example: I tried to change the query to a 'make table' so that whatever the
selection is will actually be stored. The idea is for a user to be able to
see their results in the form of a report. My guess is that I should get it
into a table first? '

Thanks, really appreciate your advice
Angeline

Duane Hookom said:
I'm not sure what you mean by "a static table".

--
Duane Hookom
MS Access MVP
--

Angeline said:
Duane,
I wander if you could help me progress with this. Now that I have the
multi-select list box working (thank you) how can I get the results of the
query into a static table. The goal is for the user to be able to see
their
results in a report which they can print off. Is this prossible?

Thanks again for your help!
Angeline

:

The code looks familiar.

The third argument in the function must be a field name from tblComp. You
are sending in a text value. It may be that you only need to change the
"SpecificCompetency" to [SpecificCompetency].

Do you have a form open named "frmMultiselectListDemo" and does this form
have a multi-select list box named "lboSpecificCompetency"?

--
Duane Hookom
MS Access MVP
--

Hello,
Hoping someone can help. I have imported a module from another database
which is executed from a query with the following sql statement:

SELECT TblComp.*
FROM TblComp
WHERE
(((IsSelectedVar("frmMultiselectListDemo","lboSpecificCompetency","SpecificCompetency"))=-1));

I think there might be something wrong with following code because I
get
an
error saying that it does not recrognise the form name. The problem in
the
code I think is from the 15th line:

Function IsSelectedVar( _
strFormName As String, _
strListBoxName As String, _
varValue As Variant) _
As Boolean
'strFormName is the name of the form
'strListBoxName is the name of the listbox
'varValue is the field to check against the listbox
Dim lbo As ListBox
Dim item As Variant
If IsNumeric(varValue) Then
varValue = Trim(Str(varValue))
End If
Set lbo = Forms(strFormName)(strListBoxName)
For Each item In lbo.ItemsSelected
If lbo.ItemData(item) = varValue Then
IsSelectedVar = True
Exit Function
End If
Next
End Function

I'd really love some help understanding what the above code means from
the
15th line onwards as that is what is highlighted in the error when you
click
on the debug button. IN particular what does "lbo" mean exactly.

Thanks so much!
Angeline
Sydney
 
T

TC

Jumping in here: you can base a report on a query, just like you can
base a form on a query. You do not hav to get the data into a table
first - in either case.

Does that help?

TC (MVP Access)
http://tc2.atspace.com
 

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