Subform cycling

  • Thread starter Thread starter Kim
  • Start date Start date
K

Kim

I have a button on a form (i'll call it MAIN) that opens a
filtered
form with a subform. They work well, but the problem I run
into is
when the person uses the scroll-wheel on the mouse, it
cycles the
records on the subform.
This can wind up with having 2 or 3 records with the same
or similar
information, because the user thinks the data has
disappeared and
re-enters it.

Is there a way to get the record(s) to remain static,
regardless?
Since only one record should be filled out for each of the
MAIN
records, there really is no need to cycle the filtered
records at all.

thanks in advance
 
Kim said:
I have a button on a form (i'll call it MAIN) that opens a
filtered
form with a subform. They work well, but the problem I run
into is
when the person uses the scroll-wheel on the mouse, it
cycles the
records on the subform.
This can wind up with having 2 or 3 records with the same
or similar
information, because the user thinks the data has
disappeared and
re-enters it.

Is there a way to get the record(s) to remain static,
regardless?
Since only one record should be filled out for each of the
MAIN
records, there really is no need to cycle the filtered
records at all.

thanks in advance

I can think of a couple of options.

1. You can use Stephen Lebans' MouseHook DLL to turn off the mouse
wheel. It's available from this link:

http://www.lebans.com/mousewheelonoff.htm

2. You add code to the subform so that it turns off its own
AllowAdditions property as soon as a record has been added. That way,
the users can't scroll to a new record after creating the first one. If
you want to pursue this approach, I have sample code to do it tucked
away somewhere.
 
Kim said:
Would that method allow for a user to later edit the record
with the same effect? [...]
I can think of a couple of options.

1. You can use Stephen Lebans' MouseHook DLL to turn off the mouse
wheel. It's available from this link:

http://www.lebans.com/mousewheelonoff.htm

2. You add code to the subform so that it turns off its own
AllowAdditions property as soon as a record has been added. That
way, the users can't scroll to a new record after creating the first
one. If you want to pursue this approach, I have sample code to do
it tucked away somewhere.

Which method? I guess you mean the second one. That would let the user
edit a record that had previously been added, but not to add a new
record without first deleteing the existing record.
 
Yes, I was referring to the 2nd one,
I would like to know your method.
the one from Lebans requires me to use a dll
which isn't always practical considering that
the form will be used on more than just one machine.
-----Original Message-----
Would that method allow for a user to later edit the record
with the same effect? [...]
I can think of a couple of options.

1. You can use Stephen Lebans' MouseHook DLL to turn off the mouse
wheel. It's available from this link:

http://www.lebans.com/mousewheelonoff.htm

2. You add code to the subform so that it turns off its own
AllowAdditions property as soon as a record has been added. That
way, the users can't scroll to a new record after creating the first
one. If you want to pursue this approach, I have sample code to do
it tucked away somewhere.

Which method? I guess you mean the second one. That would let the user
edit a record that had previously been added, but not to add a new
record without first deleteing the existing record.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


.
 
Kim said:
Yes, I was referring to the 2nd one,
I would like to know your method.
the one from Lebans requires me to use a dll
which isn't always practical considering that
the form will be used on more than just one machine.

I question that consideration, given that running the database "on more
than just one machine" really should be done by splitting the database
into front-end and back-end modules anyway, with a copy of the front-end
installed on each user's PC. And if you're going to install the
front-end on each user's PC as you should, then you can install the
mousehook.dll at the same time.

However, I'd be happy to tell you how to implement the method I
described, anyway. It's pretty simple. In the subform's code module,
place the following:

'----- start of code for subform -----
Public Sub LimitRecords()

Const conRecLimit = 1

With Me.RecordsetClone
If .RecordCount > 0 Then .MoveLast
Me.AllowAdditions = (.RecordCount < conRecLimit)
End With

End Sub

Private Sub Form_Current()

LimitRecords

End Sub

'----- end of code for subform -----

In the *main* form's code module, place code similar to the following:

'----- start of code for main form -----
Private Sub Form_Current()

Call Me.sfSubformName.Form.LimitRecords

End Sub
'----- end of code for main form -----

You must substitute, for "sfSubformName" in the above procedure, the
name of the subform control on the main form. Note that that control
may or may not have the same name as the form object that it displays,
but it's the name of the control we want.
 
I do use the frontend, but because we're on a network,
we're not allowed to install anything without approval
(even if it's as simple as a non activeX dll).

The code you provided allowed me to bypass that hassle
and it works perfectly.

thank you very much.
 
Dear Dirk:

To this point, I've never used anything that needed me to install a .dll.
You mention installing a .dll simultaneously with a front end. How does one
install a .dll? Is it as simple as copying the .dll file itself?

Thanks!
Fred Boer
 
Actually, Dirk, never mind.. I visited Stephen's site, and I see that in the
case of the mousehook.dll, it is just a file copy process. My creaky memory
also kicked in and I remembered that I *have* registered a .dll (MzTools),
although it was a while ago...

Thanks anyway!
Fred

P.S.Wouldn't it be nice if I *always* answered my own questions? <g>
 
Kim said:
I do use the frontend, but because we're on a network,
we're not allowed to install anything without approval
(even if it's as simple as a non activeX dll).

Ah, I see.
The code you provided allowed me to bypass that hassle
and it works perfectly.

thank you very much.

You're welcome.
 
Fred Boer said:
Dear Dirk:

To this point, I've never used anything that needed me to install a
.dll. You mention installing a .dll simultaneously with a front end.
How does one install a .dll? Is it as simple as copying the .dll file
itself?

Fred -

In this particular case I think all you have to do is copy the .dll file
to the designated folder. In other cases one might have to register it
using the regsvr32.exe program.
 
Back
Top