Hi,
I have a simple form with one record displayed with just a couple fields. I have an unbound textbox and command button to use as a search field to find a certain record. The problem is that I'm searching on the "TN" field which is stored in the table with a mask "000 0 00 00" which causes a problem with the search because it ends up taking the string from the unbound textbox without the mask "000000000". So there's no result returned.
I'm not sure this makes any sense....
Here's the code for the search
Private Sub Command18_Click()
Dim SearchTN As String
Dim TNs As String
If IsNull(Me![SearchTN]) Or (Me![SearchTN]) = "" Then
MsgBox "Please Enter A TN to Search!", vbOKOnly, "Invalid Search!"
Me![SearchTN].SetFocus
Exit Sub
End If
DoCmd.ShowAllRecords
DoCmd.GoToControl ("TNs")
DoCmd.FindRecord Me!SearchTN
If Me!SearchTN = Me!TNs Then
MsgBox "TN Found:" & Me!SearchTN
Else
MsgBox "Match Not Found For: " & Me!SearchTN & " - Please Try Again."
Me.SearchTN.SetFocus
End If
End Sub
I have a simple form with one record displayed with just a couple fields. I have an unbound textbox and command button to use as a search field to find a certain record. The problem is that I'm searching on the "TN" field which is stored in the table with a mask "000 0 00 00" which causes a problem with the search because it ends up taking the string from the unbound textbox without the mask "000000000". So there's no result returned.
I'm not sure this makes any sense....
Here's the code for the search
Private Sub Command18_Click()
Dim SearchTN As String
Dim TNs As String
If IsNull(Me![SearchTN]) Or (Me![SearchTN]) = "" Then
MsgBox "Please Enter A TN to Search!", vbOKOnly, "Invalid Search!"
Me![SearchTN].SetFocus
Exit Sub
End If
DoCmd.ShowAllRecords
DoCmd.GoToControl ("TNs")
DoCmd.FindRecord Me!SearchTN
If Me!SearchTN = Me!TNs Then
MsgBox "TN Found:" & Me!SearchTN
Else
MsgBox "Match Not Found For: " & Me!SearchTN & " - Please Try Again."
Me.SearchTN.SetFocus
End If
End Sub