InputBox - Error 3464 Data Type Mismatch

PatAccess

Registered User.
Local time
Today, 09:46
Joined
May 24, 2017
Messages
284
Good day all,

I have a table where the ID is an auto number type.
I have a form with an "on click event" for a cmd bttn and the following code:

Private Sub Command12_Click()
Dim AddReqNo As String
AddReqNo = InputBox("Please enter the Request No. from your email", "Request No. Entry")
DoCmd.OpenForm "Frm_AirTravel", acNormal, , "RequestID='" & AddReqNo & "'"
End Sub

When the user clicks on the bttn the Inputbox shows up but it does not open the form where the RequestID is = the data entered into the inputbox. Instead it gives me Error 3464 Data Type Mismatch.

Can someone please help me? :banghead:

Thank you
 
ID is an autonumber
what is RequestID? You have it set up to be text?
I think you expect a number, but I don't know your application.
 
Last edited:
The ID is the RequestID I just renamed it and it is an auto number type
When I make it this way
Private Sub Command12_Click()
Dim AddReqNo As String
AddReqNo = InputBox("Please enter the Request No. from your email", "Request No. Entry")
DoCmd.OpenForm "Frm_AirTravel", acNormal, , "RequestID=" & AddReqNo & ""
End Sub

It has a parameter issue and does not open the form

Thank you,
 
Try
DoCmd.OpenForm "Frm_AirTravel", acNormal, , "RequestID=" & Clng(AddReqNo)
 
Now I'm getting type mismatch error 13
I also tried CInt(AddReqNo) but same result
 
Is the field in the recordsource RequestID or just ID?

Did you try using ID and not RequestID?

What is the recordsource of your form?
Post the SQL if it is an sql string.

Can you post the design of your table as a jpg?
 
The source of the form is a table
The field Control source is RequestID from that table and it has I've created this increment format "AirTavelReq"0000000...Would that make a difference?
 
??? not sure what you are showing???

I mocked up your set up with 1 of my tables
My table is Animal
AnimalID autonumber PK
AName short text

Here's my data
AnimalId AName
0 Geronimo
1 Spot
2 Jim
3 Sam
4 David
5 BlueEyes
6 Capitan
7 Johnny

I created a blank form and added a button with the following click event

Code:
Private Sub Command22_Click()
    Dim AddReqNo As String
    AddReqNo = InputBox("Please enter the Request No. from your email", "Request No. Entry")
    DoCmd.OpenForm "animal2frm", acNormal, , "animalID= " & AddReqNo
End Sub

If I enter 0, I get Geronimo record
If I enter 5, I get BlueEyes record

Here is my animal2frm
attachment.php


The animal2frm is bound to table animal
AnimalId is my control source

Good luck.
 

Attachments

  • animal2frm.png
    animal2frm.png
    9.3 KB · Views: 197
Last edited:
Thank you very much. It works. I had to revert to the original format for the AutoNumber. I had "AirTravelReq"000000 in the format. I changed it back to increment.
Thanks again for your help!
 

Users who are viewing this thread

Back
Top Bottom