data type mismatch error opening form

xBirdman

Registered User.
Local time
Today, 09:31
Joined
Oct 14, 2019
Messages
38
I have an access multiple item form that pulls a list of related cases for the user to view and edit. Selecting a specific record, the user can open that case to edit information on a screen showing the entire record.

It has worked smoothly until this morning it didn't. I had it set as an Open Form macro action using the button's onClick. I included a where condition as

Code:
="[CaseID]=" & [CaseID]

As I said, this has worked. This morning it threw an unspecified error. I deleted it and decided to just code the action. I used:

Code:
    Dim stLinkCriteria As String
    
    stLinkCriteria = "[caseID] = '" & Me.caseID & "'"
    
    DoCmd.OpenForm "frmEditAllegationLevel", acNormal, , stLinkCriteria

I'm getting a data type mismatch error (3464) when I try to use this. I cannot for the life of me figure out why this won't work. I'm sure there's something minor I'm doing wrong. I've also tried using "Me.caseID.value" and using the upper case (CaseID) as in the macro, but the fields it is pulling start lower case (caseID). Also, both forms are pulling or using data from the same underlying numeric field. How can they be throwing a data type mismatch.

When I rebuild the macro with the original code, it works, but I'd like to be able to do other things that are more accessible in vba. I don't trust the macros that much because they seem more prone to glitching.

thoughts?
 
Hi. Since you said it is a "number" field, then you shouldn't need a string delimiter in your code. So, try removing the single quotes in your code to see if the error goes away.
 
:p:p:p

I'll illustrate what dbGuy is saying:
Code:
CHANGE THIS:

stLinkCriteria = "[caseID] = '" & Me.caseID & "'"

TO THIS:

stLinkCriteria = "[caseID] = " & Me.caseID
you had it right the first time my friend!
 
Hi. Since you said it is a "number" field, then you shouldn't need a string delimiter in your code. So, try removing the single quotes in your code to see if the error goes away.

Good grief... you know how sometimes, under stress, you get too close to things and can't see the obvious? I think every other time I've used that type of condition it involved string variables and therefore I just grabbed my pre-existed code and popped it in.

Thanks DBguy!
 
Good grief... you know how sometimes, under stress, you get too close to things and can't see the obvious? I think every other time I've used that type of condition it involved string variables and therefore I just grabbed my pre-existed code and popped it in.

Thanks DBguy!
Hi. We know what you mean. Glad Adam and I could assist. Good luck with your project.
 
it was just you. i did nothing. ;)

In this case after it was pointed out, I knew exactly what to do to fix, but in many cases I still need an example or assist to get things working just right. However, just being willing to engage with folks and try to help is always a positive. And appreciated. Cheers!
 

Users who are viewing this thread

Back
Top Bottom