Frustrated with Form/Subform

  • Thread starter Afrosheen via AccessMonster.com
  • Start date
A

Afrosheen via AccessMonster.com

Good morning. It's me again

Here is my situation. I have one main form that is tabbed "frmRosterTab". I
have a subform "RosterSub1" on that tab. I also have a button that when it is
pressed it unhides another sub form "SubFrmFind". It is this subform I have
questions/problems with.
By it's self it works almost the way I want it to. With the other forms it
doesn't want to work at all. This is where I need the help.

I'm using a filter on the "SubFrmFind". On this subform I have 2 buttons.
Next and Previous. What I want to do is as I move through the filter records
based on the beginning and the end of the records the buttons will be Enabled
= true or Enabled = false. This is the code I have. And like I said, by it's
self works almost fine and I can deal with it.

Private Sub Form_Current()
cmdPrevious.Enabled = Not Me.CurrentRecord = 1
cmdNext.Enabled = Me.CurrentRecord = 1 Or Me.CurrentRecord < Me.
RecordsetClone.RecordCount
End Sub

This is the code that creates the filter:

strWhere = "[lname] Like '" & Me!txtSearch & "' "
Filter = strWhere
FilterOn = True

If Me.RecordsetClone.RecordCount = 0 Then
Call MsgBox("Boo-Hoo, No records found!", vbInformation, Application.Name)
Else
With Me.RecordsetClone
.MoveLast
End With
txtSearch = ""
cmdexit.Enabled = True
End If

I sure would appreciate any help.
Thank you.
 
M

Marshall Barton

Afrosheen said:
Here is my situation. I have one main form that is tabbed "frmRosterTab". I
have a subform "RosterSub1" on that tab. I also have a button that when it is
pressed it unhides another sub form "SubFrmFind". It is this subform I have
questions/problems with.
By it's self it works almost the way I want it to. With the other forms it
doesn't want to work at all. This is where I need the help.

I'm using a filter on the "SubFrmFind". On this subform I have 2 buttons.
Next and Previous. What I want to do is as I move through the filter records
based on the beginning and the end of the records the buttons will be Enabled
= true or Enabled = false. This is the code I have. And like I said, by it's
self works almost fine and I can deal with it.

Private Sub Form_Current()
cmdPrevious.Enabled = Not Me.CurrentRecord = 1
cmdNext.Enabled = Me.CurrentRecord = 1 Or Me.CurrentRecord < Me.
RecordsetClone.RecordCount
End Sub

This is the code that creates the filter:

strWhere = "[lname] Like '" & Me!txtSearch & "' "
Filter = strWhere
FilterOn = True

If Me.RecordsetClone.RecordCount = 0 Then
Call MsgBox("Boo-Hoo, No records found!", vbInformation, Application.Name)
Else
With Me.RecordsetClone
.MoveLast
End With
txtSearch = ""
cmdexit.Enabled = True
End If

It does not make sense to me that subform SubFrmFind can
work by itself when you want it to manipulate a different
subform. To work by itself, it would have to bound to a
table/query and display records for navigation. But, I
think you said the Next/Previous buttons on SubFrmFind are
supposed to navigate threough the records in the other
subform.

If that's what you are trying to do, then the filter needs
to be applied to the other form:

With Parent.frmRosterTab.Form
.Filter = "[lname] Like '" & Me!txtSearch & "' "
.FilterOn = True
With .RecordsetClone
If .RecordCount = 0 Then
MsgBox "Boo-Hoo, No records found!", _
vbInformation, Application.Name
Else
.MoveLast
End If
End With
End With
txtSearch = ""
cmdexit.Enabled = True

The Current event code you posted also does not make sense.
It nust be in the subform with the data records, but I think
you said the buttons are in subform SubFrmFind. In that
situation, the buttons can not be addressed using Me.

You really need to think this through and clarify which form
contains the data and which form contains the search and
buttons. Then figure out how to refer to the stuff that is
not in the form with the code.
 
A

Afrosheen via AccessMonster.com

Sorry it took me so long to get back to you. When I was running the subform
by its self I did have it bound to a table [dah]. I did get the problem
solved by leaving it bound to the table and now it works.

Thanks for the help.

Marshall said:
Here is my situation. I have one main form that is tabbed "frmRosterTab". I
have a subform "RosterSub1" on that tab. I also have a button that when it is
[quoted text clipped - 30 lines]
cmdexit.Enabled = True
End If

It does not make sense to me that subform SubFrmFind can
work by itself when you want it to manipulate a different
subform. To work by itself, it would have to bound to a
table/query and display records for navigation. But, I
think you said the Next/Previous buttons on SubFrmFind are
supposed to navigate threough the records in the other
subform.

If that's what you are trying to do, then the filter needs
to be applied to the other form:

With Parent.frmRosterTab.Form
.Filter = "[lname] Like '" & Me!txtSearch & "' "
.FilterOn = True
With .RecordsetClone
If .RecordCount = 0 Then
MsgBox "Boo-Hoo, No records found!", _
vbInformation, Application.Name
Else
.MoveLast
End If
End With
End With
txtSearch = ""
cmdexit.Enabled = True

The Current event code you posted also does not make sense.
It nust be in the subform with the data records, but I think
you said the buttons are in subform SubFrmFind. In that
situation, the buttons can not be addressed using Me.

You really need to think this through and clarify which form
contains the data and which form contains the search and
buttons. Then figure out how to refer to the stuff that is
not in the form with the code.
 

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

Top