Type mismatch inconsistency bet. forms

cath_hopes

Registered User.
Local time
Today, 16:32
Joined
Oct 17, 2007
Messages
52
I've the following piece of code that works fine in one form but throws up a runtime error message '13' that says 'Type Mismatch' in another form.

The code is:
Private Sub Combo48_AfterUpdate()
Dim ONumID As Integer
ONumID = Combo48!Column(0)
DoCmd.ApplyFilter , "[Office ID] = ONumID"
End Sub

It falls over when it tries to assign the Combo value to ONumID. I'm beginning to notice with other code that will work in one form but not in another. Is this an Access 2007 bug or are there coding rules about different forms about which I am not aware?

thanks!
 
Are you sure that your Office ID is an Integer and not Long Integer?
 
I think your type mismatch stems from using bang (!) when referring to a property. Try

ONumID = Combo48.Column(0)

in stead (.)

I've never used applyfilter, but assuming it does work, I think you should concatenate the value into the string you pass to it, not the variable name

DoCmd.ApplyFilter , "[Office ID] = " & ONumID
 
Thanks both Bob and Roy - my coding problem is now solved!
The type mismatch did stem from using bang (!) when referring to a property.
Not only does:
DoCmd.ApplyFilter , "[Office ID] = " & ONumID
work, but so does:
DoCmd.ApplyFilter , "[Office ID] = " & Combo48.Column(0)
Hurrah!
 

Users who are viewing this thread

Back
Top Bottom