PDA

Click to See Complete Forum and Search --> : [RESOLVED] combo box - please help


rochak
Aug 8th, 2005, 04:27 AM
Hi,

I am using the following VBA code but it is giving me a Type Mismatch error on the line marked below.

Private Sub Combo0_AfterUpdate()

Dim sql As String
Dim rst As Recordset

sql = "Select * from MailboxCats where MailboxName= '" & Me.Combo0.Value & "'"


Set rst = CurrentDb.OpenRecordset(sql) <--------- TYPE MISMATCH ERROR

'extract the sub category field

While Not rst.EOF
Combo2.AddItem rst.Fields(1) 'I am extracting the second field
rst.MoveNext
Wend

End Sub


Please help. Thanks

nagasrikanth
Aug 8th, 2005, 05:59 AM
Hi...

I thnk mail box name field is not a text field...it might be a numeric field...
u need to remove the single quote ( ' ) in the sql statement
sql = "Select * from MailboxCats where MailboxName= " & Me.Combo0.Value & ""

Try it...it definetly works...

All the best.. :thumb:
Anu..

rochak
Aug 9th, 2005, 08:44 PM
Anu, unfortunately mailboxname is a text field. Removing the single quote gives a different error that no records were found in query SQL.

Any other ideas? Thanks

rochak
Aug 10th, 2005, 10:56 PM
Thanks.. I solved the problem on my own.

nagasrikanth
Aug 12th, 2005, 02:48 AM
Could u please tell me whats the problem is....