A
Afrosheen via AccessMonster.com
Thanks for reading this.
I have a sub form that I use for a search box and when I type in a dummy name
to check if the search is correct, the detail section blanks out. Of course,
when I type in the correct name it is ok. I'm just wondering how I can keep
the screen in the detail section on.
I do have:
Allow Additions - Yes
Data Entry - No
I know if I change the Data Entry to Yes then the detail will stay on. The
problem with that is when I press next, it will go to the next record. If
it's on the last record then it will show blank record and I have to press
the Next button twice more for it to say "End of Records"
This is the search code:
Private Sub txtSearch_AfterUpdate()
10 On Error GoTo txtSearch_AfterUpdate_Error
'Check txtSearch for Null value or Nill Entry first.
20 If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then
30 MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criterion!
"
40 Me![txtSearch].SetFocus
50 Exit Sub
60 End If
'---------------------------------------------------------------
'Performs the search using a filter entered into txtSearch and
evaluates this against values in lName
'strwhere = txtSearch
70 strWhere = "[lname] = '" & Me!txtSearch & "'"
80 Filter = strWhere
90 FilterOn = True
100 If Me.RecordsetClone.RecordCount = 0 Then
110 Call MsgBox("Boo-hoo, no records found!", vbQuestion, Application.
Name)
120 Else
130 With Me.RecordsetClone
140 .MoveLast
150 If Me.RecordsetClone.RecordCount > 1 Then
160 cmdNext.Enabled = True
170 Else
180 cmdNext.Enabled = False
190 End If
200 End With
210 txtSearch = ""
220 cmdExit.Enabled = True
230 End If
240 On Error GoTo 0
250 Exit Sub
txtSearch_AfterUpdate_Error:
260 Err.Description = Err.Description & " In Procedure " &
"txtSearch_AfterUpdate of VBA Document Form_SubFrmFind"
270 Call LogError(Err.Number, Err.Description, "txtSearch_AfterUpdate")
End Sub
I have a sub form that I use for a search box and when I type in a dummy name
to check if the search is correct, the detail section blanks out. Of course,
when I type in the correct name it is ok. I'm just wondering how I can keep
the screen in the detail section on.
I do have:
Allow Additions - Yes
Data Entry - No
I know if I change the Data Entry to Yes then the detail will stay on. The
problem with that is when I press next, it will go to the next record. If
it's on the last record then it will show blank record and I have to press
the Next button twice more for it to say "End of Records"
This is the search code:
Private Sub txtSearch_AfterUpdate()
10 On Error GoTo txtSearch_AfterUpdate_Error
'Check txtSearch for Null value or Nill Entry first.
20 If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then
30 MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criterion!
"
40 Me![txtSearch].SetFocus
50 Exit Sub
60 End If
'---------------------------------------------------------------
'Performs the search using a filter entered into txtSearch and
evaluates this against values in lName
'strwhere = txtSearch
70 strWhere = "[lname] = '" & Me!txtSearch & "'"
80 Filter = strWhere
90 FilterOn = True
100 If Me.RecordsetClone.RecordCount = 0 Then
110 Call MsgBox("Boo-hoo, no records found!", vbQuestion, Application.
Name)
120 Else
130 With Me.RecordsetClone
140 .MoveLast
150 If Me.RecordsetClone.RecordCount > 1 Then
160 cmdNext.Enabled = True
170 Else
180 cmdNext.Enabled = False
190 End If
200 End With
210 txtSearch = ""
220 cmdExit.Enabled = True
230 End If
240 On Error GoTo 0
250 Exit Sub
txtSearch_AfterUpdate_Error:
260 Err.Description = Err.Description & " In Procedure " &
"txtSearch_AfterUpdate of VBA Document Form_SubFrmFind"
270 Call LogError(Err.Number, Err.Description, "txtSearch_AfterUpdate")
End Sub