I have a form that uses a custom dialog search form to force users to search for an entry that may already exist before entering new data.
It all works (or used to work) just fine, but I started noticing blank records in the form. It appears that when certain users click "add new record" (from my custom search form), they are taken to a new record and can proceed as normal, but the form now has a blank record inserted prior to the one that the code takes you to.
This problem wasn't happening when I (db administrator) entered new records, but of course, now suddenly, it does it whenever I do it, too.
Aside from the issue of users, does anyone have an idea why the form is adding blank records?
Here is the code for both the "search" form and the "searchresults" form:
Private Sub OKButton_Click()
Dim stRecCount As String
'Count values of possible record matches in the database
stRecCount = DCount("*", "qryApplicantMainForm", _
"[FName] Like '*' & Forms!frmAQApplicants![FName] & '*' OR [LName] Like
'*' & Forms!frmAQApplicants![LName] & '*'")
If stRecCount > 0 Then 'Count returns results; prompt
user to view list
DoCmd.OpenForm "frmSearchResultsAQAppl" 'Open form with list
box to display matches
Exit Sub 'Do Nothing
End If
End Sub
Private Sub cmdOK_Click()
DoCmd.Close acForm, "frmSearchAQApplicants"
DoCmd.OpenForm "frmAQApplicants", acNormal, , "[ApplID]=" &
Me.lstNameMatches
DoCmd.Close acForm, "frmSearchResultsAQAppl"
End Sub
Private Sub cmdAddNewRecord_Click()
On Error GoTo Err_cmdAddNewRecord_Click
DoCmd.Close acForm, "frmSearchAQApplicants"
DoCmd.Close acForm, "frmSearchResultsAQAppl"
DoCmd.OpenForm "frmContacts", , , , acFormAdd
DoCmd.GoToRecord , , acNewRec
Exit_cmdAddNewRecord_Click:
Exit Sub
Err_cmdAddNewRecord_Click:
MsgBox Err.Description
Resume Exit_cmdAddNewRecord_Click
End Sub
Private Sub lstNameMatches_DblClick(Cancel As Integer)
DoCmd.Close acForm, "frmSearchAQApplicants"
DoCmd.OpenForm "frmAQApplicants", acNormal, , "[ApplID]=" & Me.lstNameMatches
DoCmd.Close acForm, "frmSearchResultsAQAppl"
End Sub
It all works (or used to work) just fine, but I started noticing blank records in the form. It appears that when certain users click "add new record" (from my custom search form), they are taken to a new record and can proceed as normal, but the form now has a blank record inserted prior to the one that the code takes you to.
This problem wasn't happening when I (db administrator) entered new records, but of course, now suddenly, it does it whenever I do it, too.
Aside from the issue of users, does anyone have an idea why the form is adding blank records?
Here is the code for both the "search" form and the "searchresults" form:
Private Sub OKButton_Click()
Dim stRecCount As String
'Count values of possible record matches in the database
stRecCount = DCount("*", "qryApplicantMainForm", _
"[FName] Like '*' & Forms!frmAQApplicants![FName] & '*' OR [LName] Like
'*' & Forms!frmAQApplicants![LName] & '*'")
If stRecCount > 0 Then 'Count returns results; prompt
user to view list
DoCmd.OpenForm "frmSearchResultsAQAppl" 'Open form with list
box to display matches
Exit Sub 'Do Nothing
End If
End Sub
Private Sub cmdOK_Click()
DoCmd.Close acForm, "frmSearchAQApplicants"
DoCmd.OpenForm "frmAQApplicants", acNormal, , "[ApplID]=" &
Me.lstNameMatches
DoCmd.Close acForm, "frmSearchResultsAQAppl"
End Sub
Private Sub cmdAddNewRecord_Click()
On Error GoTo Err_cmdAddNewRecord_Click
DoCmd.Close acForm, "frmSearchAQApplicants"
DoCmd.Close acForm, "frmSearchResultsAQAppl"
DoCmd.OpenForm "frmContacts", , , , acFormAdd
DoCmd.GoToRecord , , acNewRec
Exit_cmdAddNewRecord_Click:
Exit Sub
Err_cmdAddNewRecord_Click:
MsgBox Err.Description
Resume Exit_cmdAddNewRecord_Click
End Sub
Private Sub lstNameMatches_DblClick(Cancel As Integer)
DoCmd.Close acForm, "frmSearchAQApplicants"
DoCmd.OpenForm "frmAQApplicants", acNormal, , "[ApplID]=" & Me.lstNameMatches
DoCmd.Close acForm, "frmSearchResultsAQAppl"
End Sub