fearmichaele
Registered User.
- Local time
- Today, 11:56
- Joined
- Jan 14, 2014
- Messages
- 34
i have read other post about this error and tried adapting their fixes to fix my error without success.
i have a form which the user enters a number in a text box in order to search for that number in a query. if the number is not found in the query I want a message box to pop up saying "number not found, check number and try again" and not open a new form.
everything i tried even if a number is entered and not located the next form opens anyway blank. i dont want the form to open if the number is not in the query. Simply, i am checking the query first to see if the number is present and if not do not open the next form, but if it is open the next form showing the information for the number entered.
i have searched other forums including this one and have not found a solution. the current code i adapted was from another forum. now when i get to the highlighted line i get run time error 3464. i cant figure out where the error is pointing to regarding data type mismatch.
the EquipmentPK is the primary key field from the table which show in the query - Tag is the field in the query that holds the number the user is searching for. me.text0 is the text box the user enters the number they want to look for. qry_Equipment_all is the name of the union query I am using.
note not all equipment have a tag number so that field on the original table is set to short text and there are null values. so i was trying to count the number of equipmentPK where the Tag field matches the me.text0 entered by the user. if the number does not exist in the query then i do not want the form "Frmqry_EquipmentAll" to open at all. if it does exist then open the form.
the code is as follows
i am now crosseyed and i am at a loss. what am i missing. any assistance is greatly apprectiated.
i have a form which the user enters a number in a text box in order to search for that number in a query. if the number is not found in the query I want a message box to pop up saying "number not found, check number and try again" and not open a new form.
everything i tried even if a number is entered and not located the next form opens anyway blank. i dont want the form to open if the number is not in the query. Simply, i am checking the query first to see if the number is present and if not do not open the next form, but if it is open the next form showing the information for the number entered.
i have searched other forums including this one and have not found a solution. the current code i adapted was from another forum. now when i get to the highlighted line i get run time error 3464. i cant figure out where the error is pointing to regarding data type mismatch.
the EquipmentPK is the primary key field from the table which show in the query - Tag is the field in the query that holds the number the user is searching for. me.text0 is the text box the user enters the number they want to look for. qry_Equipment_all is the name of the union query I am using.
note not all equipment have a tag number so that field on the original table is set to short text and there are null values. so i was trying to count the number of equipmentPK where the Tag field matches the me.text0 entered by the user. if the number does not exist in the query then i do not want the form "Frmqry_EquipmentAll" to open at all. if it does exist then open the form.
the code is as follows
Private Sub Command4_Click()
On Err GoTo Errhand
Dim tagtemp As String
Dim stDocName As String
Dim stLinkCriteria As String
Dim intHolder As Integer
stLinkCriteria = "[Tag] =" & Me.Text0
stDocName = "qryfrm_EquipmentAll"
intHolder = DCount("EquipmentPK", "qry_Equipment_all", stLinkCriteria)
If intHolder > 0 Then
DoCmd.OpenForm stDocName, acNormal, , stLinkCriteria, , acDialog
Else
MsgBox "Tag number not located, please check and reenter", vbOKOnly
End If
Exit_Command4_Click:
Exit Sub
Errhand:
MsgBox "Error number = " & Err.Number & " and Description is " & Err.Description, vbOKOnly
GoTo Finish
Finish:
End Sub
i am now crosseyed and i am at a loss. what am i missing. any assistance is greatly apprectiated.
Last edited: