I have hit a wall and I am completely at a loss.
So I have a Form in MS Access. In it I have a single text box and a single button. When I type in a number in the text box and then click the button it opens a public sub which then runs a few queries, updates the database, displays a text box and then clears out the text box. This all works perfectly.
My issue is trying to do the exact same thing with hitting enter in the text box. The strangest thing is that the code works fine right after I open up the form, but all subsequent attempts give the following error until I close the form and reopen it:
Data type mismatch in criteria expression. For the life of me I cannot figure out why it does what I want the first time, then falls apart on me.
Here is the complete VBA code for reference:
Option Compare Database Public Sub Cut_Update() On Error GoTo Cut_Update_Err DoCmd.OpenQuery "UPDATE_WIP_Cut", acViewNormal, acEdit DoCmd.OpenQuery "UPDATE_LastRun", acViewNormal, acEdit MsgBox "Database Updated" [Forms]![Portal_02_Cut]![WO_Num].Value = "" Cut_Update_Exit: Exit Sub Cut_Update_Err: MsgBox Error$ Resume Cut_Update_Exit End Sub '------------------------------------------------------------ ' Return in Textbox ' '------------------------------------------------------------ Private Sub WO_Num_KeyUp(KeyCode As Integer, Shift As Integer) If KeyCode = 13 Then Call Cut_Update Me.Refresh End If End Sub '------------------------------------------------------------ ' Command2_Click ' '------------------------------------------------------------ Private Sub Command2_Click() Call Cut_Update End Sub
Me.Refresh?