DAO Help please!

AndyShuter

Registered User.
Local time
Today, 17:36
Joined
Mar 3, 2003
Messages
151
Could somebody pls help me with this code?

I am trying to create a query based on the values of a listbox, buy get the following error

Compile Error
"User Defined Type Not Defined"

I think it's something to do with the bits in orange?

Dim MyDB As DAO.Database
Dim qdf As DAO.QueryDef

Dim i As Integer, strSQL As String
Dim strWhere As String, strIN As String
Dim flgAll As Boolean
Set MyDB = CurrentDb()
strSQL = "SELECT * FROM CurrentStatus"

'create the IN string by looping thru the listbox
For i = 0 To Me.List139.ListCount - 1
If Me.List139.Selected(i) Then
If Me.List139.Column(0, i) = "All" Then
flgAll = True
End If
strIN = strIN & "'" & Me.List139.Column(0, i) & "',"
End If
Next i

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

'if "All" was selected, don't add the WHERE condition
If Not flgAll Then
strSQL = strSQL & strWhere
End If

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

Many Thanks

Andy
 
Curious, i had the same problem :P

try to go on tools --> references and then activate Microsoft DAO 3.6 Object Libray
 
Thanks,

Cant see that option on my list - I'm running Office XP,

does that make a difference?
 
PS - just looked at the program where the source code comes from & you are right, i needs this to run!

Why doesn't my program show it??!!
 
You will have a DAO library - maybe not 3.6 - but you will have one.
 

Users who are viewing this thread

Back
Top Bottom