0011268899
IS-IT--Management
I have a 'main menu' form in which a user can click on a button to edit a record. After clicking on the 'edit record' button, another form called 'input search' pops up. The user can enter in a ssn#, last name, etc to locate a record. Well when a user enters in any one of these pieces of information to locate a customer and clicks on the 'search' button, I get a run time error 2105: you can't go to the specified record. When I click on the debug option, the line that's highlighted is:
DoCmd.GoToRecord acDataForm, "Master-Main", acLast.
What's strange is I have another form (let's call it 'Test Record' form) and I have a search button on that form that when clicked, it'll pop up the same 'input search' form that I mentioned earlier. When you use the search option from the Test Record form, the appropriate record is found and I don't get an error message. Enclosed is my code:
Private Sub CmdSearch_Click()
Dim TextEntry
If Not IsNull(SearchText) And SearchText <> "" Then
TextEntry = SearchText
If Frame2 = 1 Then
DoCmd.OpenForm "Master-Main"
DoCmd.Maximize
DoCmd.GoToRecord acDataForm, "Master-Main", acLast
Forms![Master-Main].[SSN].SetFocus
DoCmd.FindRecord TextEntry, , , , True
If Forms![Master-Main].[SSN] <> TextEntry Then
MsgBox "Sorry, No record matching your entry could be found!" & _
Chr(10) & Chr(10) & "Please re-enter or click the Exit button to abort.", vbInformation
Exit Sub
End If
DoCmd.Close acForm, "InputSearch", acSaveNo
ElseIf Frame2 = 2 Then
DoCmd.OpenForm "Master-Main"
DoCmd.Maximize
DoCmd.GoToRecord acDataForm, "Master-Main", acLast
Forms![Master-Main].[CONTROL_Nr].SetFocus
DoCmd.FindRecord TextEntry, , , , True
If Forms![Master-Main].[CONTROL_Nr] <> TextEntry Then
MsgBox "Sorry, No record matching your entry could be found!" & _
Chr(10) & Chr(10) & "Please re-enter or click the Exit button to abort.", vbInformation
Exit Sub
End If
DoCmd.Close acForm, "InputSearch", acSaveNo
ElseIf Frame2 = 3 Then
DoCmd.OpenForm "Master-Main"
DoCmd.Maximize
DoCmd.GoToRecord acDataForm, "Master-Main", acLast
Forms![Master-Main].[LAST_NAME].SetFocus
DoCmd.FindRecord TextEntry, , , , True
If Forms![Master-Main].[LAST_NAME] <> TextEntry Then
MsgBox "Sorry, No record matching your entry could be found!" & _
Chr(10) & Chr(10) & "Please re-enter or click the Exit button to abort.", vbInformation
Exit Sub
End If
DoCmd.Close acForm, "InputSearch", acSaveNo
Else
MsgBox "You must select the criteria type!", vbCritical
Exit Sub
End If
Else
MsgBox "You must enter search criteria.", vbCritical
Exit Sub
End If
End Sub
Any help is greatly appreciated. I am fairly new to Access and came into the development of this database at the far end of the project so bear with me. Thanks in advance.
DoCmd.GoToRecord acDataForm, "Master-Main", acLast.
What's strange is I have another form (let's call it 'Test Record' form) and I have a search button on that form that when clicked, it'll pop up the same 'input search' form that I mentioned earlier. When you use the search option from the Test Record form, the appropriate record is found and I don't get an error message. Enclosed is my code:
Private Sub CmdSearch_Click()
Dim TextEntry
If Not IsNull(SearchText) And SearchText <> "" Then
TextEntry = SearchText
If Frame2 = 1 Then
DoCmd.OpenForm "Master-Main"
DoCmd.Maximize
DoCmd.GoToRecord acDataForm, "Master-Main", acLast
Forms![Master-Main].[SSN].SetFocus
DoCmd.FindRecord TextEntry, , , , True
If Forms![Master-Main].[SSN] <> TextEntry Then
MsgBox "Sorry, No record matching your entry could be found!" & _
Chr(10) & Chr(10) & "Please re-enter or click the Exit button to abort.", vbInformation
Exit Sub
End If
DoCmd.Close acForm, "InputSearch", acSaveNo
ElseIf Frame2 = 2 Then
DoCmd.OpenForm "Master-Main"
DoCmd.Maximize
DoCmd.GoToRecord acDataForm, "Master-Main", acLast
Forms![Master-Main].[CONTROL_Nr].SetFocus
DoCmd.FindRecord TextEntry, , , , True
If Forms![Master-Main].[CONTROL_Nr] <> TextEntry Then
MsgBox "Sorry, No record matching your entry could be found!" & _
Chr(10) & Chr(10) & "Please re-enter or click the Exit button to abort.", vbInformation
Exit Sub
End If
DoCmd.Close acForm, "InputSearch", acSaveNo
ElseIf Frame2 = 3 Then
DoCmd.OpenForm "Master-Main"
DoCmd.Maximize
DoCmd.GoToRecord acDataForm, "Master-Main", acLast
Forms![Master-Main].[LAST_NAME].SetFocus
DoCmd.FindRecord TextEntry, , , , True
If Forms![Master-Main].[LAST_NAME] <> TextEntry Then
MsgBox "Sorry, No record matching your entry could be found!" & _
Chr(10) & Chr(10) & "Please re-enter or click the Exit button to abort.", vbInformation
Exit Sub
End If
DoCmd.Close acForm, "InputSearch", acSaveNo
Else
MsgBox "You must select the criteria type!", vbCritical
Exit Sub
End If
Else
MsgBox "You must enter search criteria.", vbCritical
Exit Sub
End If
End Sub
Any help is greatly appreciated. I am fairly new to Access and came into the development of this database at the far end of the project so bear with me. Thanks in advance.