data won't display properly

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I created a subform to be able display my criteria from my 3 combo boxes
On my last combo box i have the following information loaded in my
afterupdate event procedure
Private Sub Combo378_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[ID] = " & Str(Nz(Me![Combo378], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
this is the last combo box from my 3 cascading combo boxes

i am trying to display the information from my criteria that i chose on the
3 combo boxes
my 1st combo boxes filters the information on my 2nd box and then filters
on my 3rd box.
when i exit out of the 3rd or choose the 3rd item, i want the data to
display on myt subfolder.

suggestions?
 
FindRecord
---

Hi Pete,

here is a technique and some generic code you might find useful...

~~~~~~~~~~~

Make one or more unbound combos on your form -- in header or footer is
best. Let the first column be invisible and be the primary key ID of the
recordsource of your form and then, on its AfterUpdate event...

=FindRecord()

this code goes behind the form:
~~~~~~~~~~~~~~~~~~~~~~~

Private Function FindRecord()

'if nothing is picked in the active control, exit
If IsNull(Me.ActiveControl) Then Exit Function

'save current record if changes were made
If me.dirty then me.dirty = false

'declare a variable to hold the primary key value to look up
Dim mRecordID As Long

'set value to look up by what is selected
mRecordID = Me.ActiveControl

'clear the choice to find
Me.ActiveControl = Null

'find the first value that matches
Me.RecordsetClone.FindFirst "IDfield = " & mRecordID

'if a matching record was found, then move to it
If Not Me.RecordsetClone.NoMatch Then
Me.Bookmark = Me.RecordsetClone.Bookmark
End If

End Function

'~~~~~~~~~~

now, as for what is wrong with your code -- perhaps your form is
filtered and the ID you are looking for is not in the filtered recordset...

Str(Nz(Me![Combo378], 0))

is not necessary -- I am assuming the bound column of your combo is a
number? You can simply do this:

Nz(Me![Combo378], 0)

-- or, even better, check for null before it gets to this statement...

Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
 
what do you mean this code goes behind the form?
where is that?


do i have to substitute something for when you write Me or...
like the example below
If IsNull(Me.ActiveControl) Then Exit Function


thx

strive4peace said:
FindRecord
---

Hi Pete,

here is a technique and some generic code you might find useful...

~~~~~~~~~~~

Make one or more unbound combos on your form -- in header or footer is
best. Let the first column be invisible and be the primary key ID of the
recordsource of your form and then, on its AfterUpdate event...

=FindRecord()

this code goes behind the form:
~~~~~~~~~~~~~~~~~~~~~~~

Private Function FindRecord()

'if nothing is picked in the active control, exit
If IsNull(Me.ActiveControl) Then Exit Function

'save current record if changes were made
If me.dirty then me.dirty = false

'declare a variable to hold the primary key value to look up
Dim mRecordID As Long

'set value to look up by what is selected
mRecordID = Me.ActiveControl

'clear the choice to find
Me.ActiveControl = Null

'find the first value that matches
Me.RecordsetClone.FindFirst "IDfield = " & mRecordID

'if a matching record was found, then move to it
If Not Me.RecordsetClone.NoMatch Then
Me.Bookmark = Me.RecordsetClone.Bookmark
End If

End Function

'~~~~~~~~~~

now, as for what is wrong with your code -- perhaps your form is
filtered and the ID you are looking for is not in the filtered recordset...

Str(Nz(Me![Combo378], 0))

is not necessary -- I am assuming the bound column of your combo is a
number? You can simply do this:

Nz(Me![Combo378], 0)

-- or, even better, check for null before it gets to this statement...

Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*



Pete said:
I created a subform to be able display my criteria from my 3 combo boxes
On my last combo box i have the following information loaded in my
afterupdate event procedure
Private Sub Combo378_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[ID] = " & Str(Nz(Me![Combo378], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
this is the last combo box from my 3 cascading combo boxes

i am trying to display the information from my criteria that i chose on the
3 combo boxes
my 1st combo boxes filters the information on my 2nd box and then filters
on my 3rd box.
when i exit out of the 3rd or choose the 3rd item, i want the data to
display on myt subfolder.

suggestions?
 
View Code, show ScreenTips, shortcut Keys
---

Hi Pete,

"> what do you mean this code goes behind the form?
where is that?"

yes,
from the design view of your form:
click on the menubar --> View, Code
OR
click on the "Code-Bracelet Icon"
-- well, I call it that anyway because that it what it looks like --
hover your mouse over every icon on the toobars that you see -- a great
way to learn.

If you do not see the tool-tips (screen-tips for the toolbar icons) pop
up in yellow boxes....

*** show Tool-tips ***

R-click your mouse anywhere to the right of an existing toolbar or menubar

Choose 'Customize' from the short-cut menu

Click the 'Options' tab

check:
-- 'Always Show Full Menus'

-- 'show ScreenTips on Toolbars'
-- 'show shortcut keys in ScreenTips'

click 'Close'

now, if you hover long enough <smile>... you should see screen-tips for
the toolbars :)


Procedures assigned directly to Event Procedures need to be Functions
.... even though they may not return a value...

a Private function is one that, as opposed to a Public procedure
probably stored in a general module, is visible only to the form it is
behind -- good thing too, since it references "Me." -- which can only be
interpreted correctly if the form is open.

There are other times, when a procedure behind the form may be called by
something else, but that is not the case here.

Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*



Pete said:
what do you mean this code goes behind the form?
where is that?


do i have to substitute something for when you write Me or...
like the example below
If IsNull(Me.ActiveControl) Then Exit Function


thx

strive4peace said:
FindRecord
---

Hi Pete,

here is a technique and some generic code you might find useful...

~~~~~~~~~~~

Make one or more unbound combos on your form -- in header or footer is
best. Let the first column be invisible and be the primary key ID of the
recordsource of your form and then, on its AfterUpdate event...

=FindRecord()

this code goes behind the form:
~~~~~~~~~~~~~~~~~~~~~~~

Private Function FindRecord()

'if nothing is picked in the active control, exit
If IsNull(Me.ActiveControl) Then Exit Function

'save current record if changes were made
If me.dirty then me.dirty = false

'declare a variable to hold the primary key value to look up
Dim mRecordID As Long

'set value to look up by what is selected
mRecordID = Me.ActiveControl

'clear the choice to find
Me.ActiveControl = Null

'find the first value that matches
Me.RecordsetClone.FindFirst "IDfield = " & mRecordID

'if a matching record was found, then move to it
If Not Me.RecordsetClone.NoMatch Then
Me.Bookmark = Me.RecordsetClone.Bookmark
End If

End Function

'~~~~~~~~~~

now, as for what is wrong with your code -- perhaps your form is
filtered and the ID you are looking for is not in the filtered recordset...

Str(Nz(Me![Combo378], 0))

is not necessary -- I am assuming the bound column of your combo is a
number? You can simply do this:

Nz(Me![Combo378], 0)

-- or, even better, check for null before it gets to this statement...

Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*



Pete said:
I created a subform to be able display my criteria from my 3 combo boxes
On my last combo box i have the following information loaded in my
afterupdate event procedure
Private Sub Combo378_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[ID] = " & Str(Nz(Me![Combo378], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
this is the last combo box from my 3 cascading combo boxes

i am trying to display the information from my criteria that i chose on the
3 combo boxes
my 1st combo boxes filters the information on my 2nd box and then filters
on my 3rd box.
when i exit out of the 3rd or choose the 3rd item, i want the data to
display on myt subfolder.

suggestions?
 

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

Back
Top