473,387 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Detecting a Sub-Form event from the Main Form 2

16
I have developed a way to enter the data from long medical document, using structure: Mainform (subform1,... subfromN). This is reflecting the logical model of data: Document(section1,section2,...sectionN).

The MainForm has only one control, subfrom, in Detail which displays consecutively section1,...sectionN. This is done by buttons "Next" and "Previous" located in MainForm's Footer.

I was quite happy with this design: subforms, which could be of hundreds' did not have class modules, thus saving memory and making design simpler.

Until data entering person claims, that it would be more comfortable if after one section is filled, the other is coming automatically, without pressing "Next".

So far I couldn't find a solution for this challenge, i.e. keeping subforms without class modules and fishing up "end of filling the subform" from the MainForm.

Any hints.
Aug 12 '09 #1
13 3753
ChipR
1,287 Expert 1GB
What's the code in your "Next" button? Just to get an idea of what you're doing exactly.
Aug 12 '09 #2
FelixS
16
It is very simple there, in class module

Private Sub NextForm_Click()
Call NextPriv(Me.Name, 1)
End Sub


NextPriv is determining which section is to include in subform.
For example, there is main form F02 and section forms F02001 - F02005
Next for F02005 is saving records and close F02. For all other the next Form is
determined as nextFrm and changes settings by statement

Forms(pubLFrmName).FormSec.SourceObject = nextFrm

This causes main form change the subform contents.
Aug 12 '09 #3
ChipR
1,287 Expert 1GB
In that case, why not have your subform after the last field is updated
Call NextPriv(Me.Parent.Name, 1) <- Though I'm not sure what the 1 is for
Aug 12 '09 #4
FelixS
16
1. 1 means 1 next, 2 means previous.
2. The main question is how to do this without class module for subform. In other words, how to fish up the situation of focus on last control in the subform, from the main form. Once more, it is very straightforward to handle this event being in subform and using class module for this subform. However, the solution, being searched is how to do this without class modules for subforms.
Aug 12 '09 #5
ChipR
1,287 Expert 1GB
I don't see any way to get the focus out of the subform without calling a macro or some code.
Aug 12 '09 #6
FishVal
2,653 Expert 2GB
To the best of my knowledge there is no way to catch subform's components events unless form which is a SourceObject of subform control has module. It could be empty, but it has to exist.
IMHO, maximum you can do without the modules is continuous polling of subform's controls.

Regards,
Fish.
Aug 13 '09 #7
FelixS
16
I have found how to do this.
Aug 17 '09 #8
ChipR
1,287 Expert 1GB
Would you mind sharing?
Aug 17 '09 #9
FelixS
16
at the moment I have only tested part of code and general Idea.
It could be done using
Private Sub Form_Timer()
<procedure to run every ### milliseconds>
End Sub

Sub Form_Load()
Me.TimerInterval = 1000
End Sub

and ActiveControl Property

Dim ctlCurrentControl As Control
Dim strControlName As String
Set ctlCurrentControl = Screen.ActiveControl
strControlName = ctlCurrentControl.Name
******************************
In fact now I am trying to solve the last outstanding problem in my task:
to set focus on the first text box in subform after the form is loaded. The name of text box is stored in variable.
So far no any working solution
Aug 17 '09 #10
FishVal
2,653 Expert 2GB
Hello, gentlemen.

Apparently, it is possible to handle events of subform controls without necessity to create module for subform's source form.
A simple example is attached.

Regards,
Fish.
Attached Files
File Type: zip WatchSbfEvents.zip (14.2 KB, 215 views)
Aug 20 '09 #11
ChipR
1,287 Expert 1GB
Hi FishVal. Brilliant solution, but a few things I'm puzzled by. If you don't mind my asking,
Why is the TimerInterval used? It seems to work fine without it.
Why does SbfCtrlHandler return the control (or anything for that matter)? What happens to that when it is returned?
Thanks for the new technique,
Chip
Aug 20 '09 #12
FishVal
2,653 Expert 2GB
@ChipR
Hi, Chip.

According to OP main form has to detect "end of input" and change subform's SourceObject to a next form thus closing current one. IMHO, even if it works it is not a good idea to close form while its control is waiting for expression to be evaluated.
So, SbfCtrlHandler() tunes mainform's timer and passes required information to maiform, exits, letting the expression (which is just call of SbfCtrlHandler()) to be evaluated and then, mainform's timer fires and does all the job.

Why does SbfCtrlHandler return the control (or anything for that matter)? What happens to that when it is returned?
SbfCtrlHandler() returns current value of the control. Since event handler of the control is defined as calculated expression, a value the expression evaluates to will be written to the control.

Regards,
Fish.
Aug 20 '09 #13
FelixS
16
Hi, FishVal, a very useful code, especially for making guided data entry (e.g. if control1.value is 2 then go to control5).
For the current task, to cycle through controls of subform and after last is attended (having been on focus) and "enter" ) trigger the "NEXT subform" procedure, I have found solution and implemented it into codes.
As I mentioned, unexpectedly the problem of focus emerged, which still is a mystery to me.

I am doing all necessary things with FormSec.setfocus expression in code.
After that, active control is the first control on the subform, this is checked by
getActiveControl() function in immediate panel. But the control itself is not painted with focus, neither is it properly respond to keyboard keystrokes . And only if I click mouse outside the MDB window, aand then inside of MDB window, the focus is coming to control.
Aug 21 '09 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: dreamer | last post by:
I need to be able to detect different screen resolutions and then resize my applications forms, objects, fonts etc, to suit. Any ideas how to go about it? I use VB 5. Many thanks in advance.
5
by: Lars Moastuen | last post by:
Hi! I'm currently playing around with a project where I need to know if an object (any object) has been altered since last check. I need this to know when an object needs to be saved... My idea...
9
by: Bijoy Naick | last post by:
I've implemented forms authentication and authorization on my application. In my Web.Config, my authorization section looks like this.. <authorization> <allow roles="admin" /> <deny users="*"...
4
by: Joe | last post by:
Hi, I have a asp.net page that checks if any one of the two cookies exists. If none of the cookies exist then redirect the user to login page. Cookie “try” doesn’t exists. I can see that...
6
by: Nathan | last post by:
How can I detect when one of the arrow keys is pressed? Thanks, Nathan
2
by: David Batt | last post by:
Hi, I need to determine when data in a datagrid bound to a dataset has changed and thus make updates accordingly. I would of thought the code below would detect when a change has been made to...
6
by: jcrouse | last post by:
I have the following mouse events assigned to a label control. Is the a way I can tell which mouse button the users has clicked with? Private Sub lblP1JoyUp_Click(ByVal sender As System.Object,...
7
by: Wayne Wengert | last post by:
I am using VB with a Windows NET application. I have a datagrid in which the user can add rows using the "*" row. I want to detect whenever the user has added a row. I found the following code at...
2
by: James | last post by:
Hi. I'm probably attempting the impossible but what the hey. I'm modifying a multi-paneled form which has 8 different listviews, To allow sorting by columns I've had to add a diffrerent handler...
1
by: batista | last post by:
Hello to all, I'm using the HScrollBar Control in one of my apps. Now the problem is how to detect that when did the scrollbar reached its right end or left end.? Please Any...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.