multi-select list box

G

Guest

I have a multi-choice problem. In the form A multi-select list box will be used so that the data entry can select as many as apply. I also want to create a query so that the selected values will be collected

Private Sub INPUT_Click(

Dim MyDB As Databas
Dim qdf As QueryDe

Dim i As Integer, strSQL As Strin
Dim strWhere As String, strIN As Strin

Set MyDB = CurrentDb(

strSQL = "SELECT * FROM IDID

'create the IN string by looping thru the listbo
For i = 0 To strConcernType.ListCount -
If strConcernType.Selected(i) The

strIN = strIN & "'" & strConcernType.Column(0, i) & "',
End I
Next

'create the WHERE string, stripping off the last comma of the IN strin
strWhere = " WHERE [bytConcernID] in (" & Left(strIN, Len(strIN) - 1) & ")
strSQL = strSQL & strWher


Me.QueryDefs.Delete "qryCustomerConcern
Set qdf = MyDB.CreateQueryDef("qryCustomerConcern", strSQL

DoCmd.OpenQuery "qryCustomerConcern", acPrevie

End Su

The problem is Compiler error says that " User Defined Type not Defined" for Dim MyDB As Databas
and Dim qdf As QueryDef

Any Help will be appreciated
 
M

MacDermott

Database and QueryDef are DAO objects;
do you have a DAO reference set?

- Turtle

lynn said:
I have a multi-choice problem. In the form A multi-select list box will be
used so that the data entry can select as many as apply. I also want to
create a query so that the selected values will be collected.
Private Sub INPUT_Click()

Dim MyDB As Database
Dim qdf As QueryDef

Dim i As Integer, strSQL As String
Dim strWhere As String, strIN As String

Set MyDB = CurrentDb()

strSQL = "SELECT * FROM IDID"

'create the IN string by looping thru the listbox
For i = 0 To strConcernType.ListCount - 1
If strConcernType.Selected(i) Then

strIN = strIN & "'" & strConcernType.Column(0, i) & "',"
End If
Next i

'create the WHERE string, stripping off the last comma of the IN string
strWhere = " WHERE [bytConcernID] in (" & Left(strIN, Len(strIN) - 1) & ")"
strSQL = strSQL & strWhere


Me.QueryDefs.Delete "qryCustomerConcern"
Set qdf = MyDB.CreateQueryDef("qryCustomerConcern", strSQL)

DoCmd.OpenQuery "qryCustomerConcern", acPreview

End Sub


The problem is Compiler error says that " User Defined Type not Defined" for Dim MyDB As Database
and Dim qdf As QueryDef.

Any Help will be appreciated!
 

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