Detail in form goes blank

  • Thread starter Afrosheen via AccessMonster.com
  • Start date
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
 
A

Allen Browne

You should be able to see the new-record row provided:
a) you have AllowAdditions turned on, AND
b) the form is bound to a table or query that's not read-only (i.e. new
records can be added.)

Since you say (a) is fine, fixing (b) would be the obvious choice. If you're
not sure whey your query is read-only, you may want to check the joins are
based on unique relations, reduce the number of tables, and so on. Here's a
trouble-shooting list:
Why is my query read-only?
at:
http://allenbrowne.com/ser-61.html
 
A

Afrosheen via AccessMonster.com

Thanks for getting back and sorry I'm taking so long at replying.

I don't need the subform for additions. I just need it as a read only form. I
guess that's why I set
Allow Additions to NO.
Data Entry to NO

I'm just using it as a look up file/form. There is nothing special about the
query. It's is based on a table and has the last name sorting Ascending.
Other than that nothing as far as I know.

The only change to the form that I can think of is the Record Source. Because
I use that subform with 2-3 other forms the Record Source may be different.
Either a query or table. That I set up when I press the "Find" button on the
main form it sets up the RecordSource.

Me.SubFrmFind.Command.RecordSource"tblRoster" {I think that's the code. I
left the program I was using it on at home. I'll see it tonight.}

Allen said:
You should be able to see the new-record row provided:
a) you have AllowAdditions turned on, AND
b) the form is bound to a table or query that's not read-only (i.e. new
records can be added.)

Since you say (a) is fine, fixing (b) would be the obvious choice. If you're
not sure whey your query is read-only, you may want to check the joins are
based on unique relations, reduce the number of tables, and so on. Here's a
trouble-shooting list:
Why is my query read-only?
at:
http://allenbrowne.com/ser-61.html
Thanks for reading this.
I have a sub form that I use for a search box and when I type in a dummy
[quoted text clipped - 61 lines]
 
A

Allen Browne

Set AllowAdditions to Yes.
Set the Locked property of your text boxes to Yes, or cancel the form's
BeforeUpdate event.

More information:
http://allenbrowne.com/casu-20.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.


Afrosheen via AccessMonster.com said:
Thanks for getting back and sorry I'm taking so long at replying.

I don't need the subform for additions. I just need it as a read only
form. I
guess that's why I set
Allow Additions to NO.
Data Entry to NO

I'm just using it as a look up file/form. There is nothing special about
the
query. It's is based on a table and has the last name sorting Ascending.
Other than that nothing as far as I know.

The only change to the form that I can think of is the Record Source.
Because
I use that subform with 2-3 other forms the Record Source may be
different.
Either a query or table. That I set up when I press the "Find" button on
the
main form it sets up the RecordSource.

Me.SubFrmFind.Command.RecordSource"tblRoster" {I think that's the code. I
left the program I was using it on at home. I'll see it tonight.}

Allen said:
You should be able to see the new-record row provided:
a) you have AllowAdditions turned on, AND
b) the form is bound to a table or query that's not read-only (i.e. new
records can be added.)

Since you say (a) is fine, fixing (b) would be the obvious choice. If
you're
not sure whey your query is read-only, you may want to check the joins are
based on unique relations, reduce the number of tables, and so on. Here's
a
trouble-shooting list:
Why is my query read-only?
at:
http://allenbrowne.com/ser-61.html
Thanks for reading this.
I have a sub form that I use for a search box and when I type in a dummy
[quoted text clipped - 61 lines]
 
A

Afrosheen via AccessMonster.com

It works great. Thanks to you. I really appreciate it.

I have another question, but if you feel I need to repost I will.

When I get to the last record by pressing the Next button, pressing Next
again will produce a blank record. Then pressing Next again will give me the
"error" so I can exit.
I'm trying to stop having it go to the blank record. This is the code"

Private Sub cmdNext_Click()
10 On Error GoTo Err_cmdNext_Click
20 Screen.PreviousControl.SetFocus
30 DoCmd.GoToRecord , , acNext

Exit_cmdNext_Click:
40 Exit Sub

Err_cmdNext_Click:

50 If Err.Number <> 2105 Then
60 Err.Description = Err.Description & " In frmabprint1"
70 Call LogError(Err.Number, Err.Description, "bday_print_click()")
80 Else
90 Call MsgBox("End of Records!! Make your choice or start over.",
vbInformation, Application.Name)
100 cmdNext.Enabled = False
110 End If

120 Resume Exit_cmdNext_Click
end sub


Allen said:
Set AllowAdditions to Yes.
Set the Locked property of your text boxes to Yes, or cancel the form's
BeforeUpdate event.

More information:
http://allenbrowne.com/casu-20.html
Thanks for getting back and sorry I'm taking so long at replying.
[quoted text clipped - 40 lines]
 
A

Afrosheen via AccessMonster.com

Hi Allen, Thanks for helping out. I really appreciate it. I did find
something I could use for the last record.


It works great. Thanks to you. I really appreciate it.

I have another question, but if you feel I need to repost I will.

When I get to the last record by pressing the Next button, pressing Next
again will produce a blank record. Then pressing Next again will give me the
"error" so I can exit.
I'm trying to stop having it go to the blank record. This is the code"

Private Sub cmdNext_Click()
10 On Error GoTo Err_cmdNext_Click
20 Screen.PreviousControl.SetFocus
30 DoCmd.GoToRecord , , acNext

Exit_cmdNext_Click:
40 Exit Sub

Err_cmdNext_Click:

50 If Err.Number <> 2105 Then
60 Err.Description = Err.Description & " In frmabprint1"
70 Call LogError(Err.Number, Err.Description, "bday_print_click()")
80 Else
90 Call MsgBox("End of Records!! Make your choice or start over.",
vbInformation, Application.Name)
100 cmdNext.Enabled = False
110 End If

120 Resume Exit_cmdNext_Click
end sub
Set AllowAdditions to Yes.
Set the Locked property of your text boxes to Yes, or cancel the form's
[quoted text clipped - 8 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top