Multi-Select List Box Code Problem

L

Lambi000

I have the following VB code that is giving me an error message:

Run-time error '424'
Object Required

It doesn't llike my Set frm statement, as if the object doesn't exist. But
exist it does as it's running other queries (it's a report parameter screen).
I suspect there's something amiss with my references as I've had to assign
some really simple ones like DAO 3.6, etc. What am I doing wrong to get this
message?

The code is below:

Public Function Combo_List()
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String
Set db = CurrentDb()
Set qdf = db.QueryDefs("qryMultiSelect")
Set frm = Form![Report Parameters] *THIS IS WHERE IT DIES*
Set ctl = frm!List90
Set ctl1 = frm!Text94
strSQL = "Select * from Purchasing where [TTYPE]="
'Concatenate to strSQL
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem) & " OR [TTYPE]="
Next varItem
'Trim the end of strSQL
strSQL = Left$(strSQL, Len(strSQL) - 12)
DoCmd.OpenQuery "qryMultiSelect", , acReadOnly
Set db = Nothing
Set qdf = Nothing
End Function

Help!

Thanks in advance.
 
D

Dennis

I think you are just missing the 's' on form - it should be forms

Set frm = Forms![Report Parameters]
 
L

Lambi000

Dennis,

You're right. But now I have a different error:

Run-time error '2450':
Scrap Reporting can't find the form 'Report Parameters' referred to in a
macro expression or Visual Basic code.

Thanks!

Dennis said:
I think you are just missing the 's' on form - it should be forms

Set frm = Forms![Report Parameters]

Lambi000 said:
I have the following VB code that is giving me an error message:

Run-time error '424'
Object Required

It doesn't llike my Set frm statement, as if the object doesn't exist. But
exist it does as it's running other queries (it's a report parameter screen).
I suspect there's something amiss with my references as I've had to assign
some really simple ones like DAO 3.6, etc. What am I doing wrong to get this
message?

The code is below:

Public Function Combo_List()
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String
Set db = CurrentDb()
Set qdf = db.QueryDefs("qryMultiSelect")
Set frm = Form![Report Parameters] *THIS IS WHERE IT DIES*
Set ctl = frm!List90
Set ctl1 = frm!Text94
strSQL = "Select * from Purchasing where [TTYPE]="
'Concatenate to strSQL
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem) & " OR [TTYPE]="
Next varItem
'Trim the end of strSQL
strSQL = Left$(strSQL, Len(strSQL) - 12)
DoCmd.OpenQuery "qryMultiSelect", , acReadOnly
Set db = Nothing
Set qdf = Nothing
End Function

Help!

Thanks in advance.
 
D

Dale Fye

Have you tried:

Set frm = Forms("Report Parameters")

--
HTH
Dale

Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



Lambi000 said:
Dennis,

You're right. But now I have a different error:

Run-time error '2450':
Scrap Reporting can't find the form 'Report Parameters' referred to in a
macro expression or Visual Basic code.

Thanks!

Dennis said:
I think you are just missing the 's' on form - it should be forms

Set frm = Forms![Report Parameters]

Lambi000 said:
I have the following VB code that is giving me an error message:

Run-time error '424'
Object Required

It doesn't llike my Set frm statement, as if the object doesn't exist. But
exist it does as it's running other queries (it's a report parameter screen).
I suspect there's something amiss with my references as I've had to assign
some really simple ones like DAO 3.6, etc. What am I doing wrong to get this
message?

The code is below:

Public Function Combo_List()
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String
Set db = CurrentDb()
Set qdf = db.QueryDefs("qryMultiSelect")
Set frm = Form![Report Parameters] *THIS IS WHERE IT DIES*
Set ctl = frm!List90
Set ctl1 = frm!Text94
strSQL = "Select * from Purchasing where [TTYPE]="
'Concatenate to strSQL
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem) & " OR [TTYPE]="
Next varItem
'Trim the end of strSQL
strSQL = Left$(strSQL, Len(strSQL) - 12)
DoCmd.OpenQuery "qryMultiSelect", , acReadOnly
Set db = Nothing
Set qdf = Nothing
End Function

Help!

Thanks in advance.
 
L

Lambi000

Dale,

That didn't work either. I'm totally stumped on this one.

Thanks!

Dale Fye said:
Have you tried:

Set frm = Forms("Report Parameters")

--
HTH
Dale

Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



Lambi000 said:
Dennis,

You're right. But now I have a different error:

Run-time error '2450':
Scrap Reporting can't find the form 'Report Parameters' referred to in a
macro expression or Visual Basic code.

Thanks!

Dennis said:
I think you are just missing the 's' on form - it should be forms

Set frm = Forms![Report Parameters]

:

I have the following VB code that is giving me an error message:

Run-time error '424'
Object Required

It doesn't llike my Set frm statement, as if the object doesn't exist. But
exist it does as it's running other queries (it's a report parameter screen).
I suspect there's something amiss with my references as I've had to assign
some really simple ones like DAO 3.6, etc. What am I doing wrong to get this
message?

The code is below:

Public Function Combo_List()
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String
Set db = CurrentDb()
Set qdf = db.QueryDefs("qryMultiSelect")
Set frm = Form![Report Parameters] *THIS IS WHERE IT DIES*
Set ctl = frm!List90
Set ctl1 = frm!Text94
strSQL = "Select * from Purchasing where [TTYPE]="
'Concatenate to strSQL
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem) & " OR [TTYPE]="
Next varItem
'Trim the end of strSQL
strSQL = Left$(strSQL, Len(strSQL) - 12)
DoCmd.OpenQuery "qryMultiSelect", , acReadOnly
Set db = Nothing
Set qdf = Nothing
End Function

Help!

Thanks in advance.
 
L

Lambi000

Guys,

I didn't have the form open and the parameters selected. Sorry about that.
The original code works fine now.

Thank you both very much:)

Lambi000 said:
Dale,

That didn't work either. I'm totally stumped on this one.

Thanks!

Dale Fye said:
Have you tried:

Set frm = Forms("Report Parameters")

--
HTH
Dale

Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



Lambi000 said:
Dennis,

You're right. But now I have a different error:

Run-time error '2450':
Scrap Reporting can't find the form 'Report Parameters' referred to in a
macro expression or Visual Basic code.

Thanks!

:

I think you are just missing the 's' on form - it should be forms

Set frm = Forms![Report Parameters]

:

I have the following VB code that is giving me an error message:

Run-time error '424'
Object Required

It doesn't llike my Set frm statement, as if the object doesn't exist. But
exist it does as it's running other queries (it's a report parameter screen).
I suspect there's something amiss with my references as I've had to assign
some really simple ones like DAO 3.6, etc. What am I doing wrong to get this
message?

The code is below:

Public Function Combo_List()
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String
Set db = CurrentDb()
Set qdf = db.QueryDefs("qryMultiSelect")
Set frm = Form![Report Parameters] *THIS IS WHERE IT DIES*
Set ctl = frm!List90
Set ctl1 = frm!Text94
strSQL = "Select * from Purchasing where [TTYPE]="
'Concatenate to strSQL
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem) & " OR [TTYPE]="
Next varItem
'Trim the end of strSQL
strSQL = Left$(strSQL, Len(strSQL) - 12)
DoCmd.OpenQuery "qryMultiSelect", , acReadOnly
Set db = Nothing
Set qdf = Nothing
End Function

Help!

Thanks in advance.
 

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