Hello
I have a single form, and want to require the user to make a selection
from a serialnumber ComboBox before being allowed to enter any other
textboxes. Also, the user should be allowed to click on an Exit button
I created and get a response.
The following code works fine without the ExitButton issue:
Private Sub SerialCombo_Exi t(Cancel As Integer)
Dim Ctl As Control
If IsNull(SerDevCo mbo) Then
MsgBox "You must enter a serial#"
Me.AnyOtherFiel d.SetFocus 'acts as a refresh
Me.SerialCombo. SetFocus 'return to field since it is empty
End If
End Sub
MY PROBLEM IS INCLUDING THE CHECK FOR a change of focus when
clicking on the ExitButton. I tried many different methods.
If Not (Screen.ActiveC ontrol.Name <> "ExitButton ") Then
ThankYou 17 2249 Ap******@gmail. com wrote: Hello
I have a single form, and want to require the user to make a selection from a serialnumber ComboBox before being allowed to enter any other textboxes. Also, the user should be allowed to click on an Exit button I created and get a response.
The following code works fine without the ExitButton issue:
Private Sub SerialCombo_Exi t(Cancel As Integer) Dim Ctl As Control If IsNull(SerDevCo mbo) Then MsgBox "You must enter a serial#" Me.AnyOtherFiel d.SetFocus 'acts as a refresh Me.SerialCombo. SetFocus 'return to field since it is empty End If End Sub
MY PROBLEM IS INCLUDING THE CHECK FOR a change of focus when clicking on the ExitButton. I tried many different methods.
If Not (Screen.ActiveC ontrol.Name <> "ExitButton ") Then
ThankYou
I created a combo box and a command button to close/exit. Here's the
code for my combo using the OnExit method.
Private Sub Combo0_Exit(Can cel As Integer)
If IsNull(Me.Combo 0) Then
Cancel = True
MsgBox "Select an item"
End If
End Sub
This works...except if I press the X button to close the window.
Now if you wanted to allow the person to exit even if the serial no is
null, what you could set, in design mode, all of the textbox controls to
Enabled = True/Locked = True. This permits only the combo to be updated
or exit button to be pressed.
In the AfterUpdate event for the combo you could do something like
If Not IsNull(Me.Combo 0) Then
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
ctl.Locked = False
Endif
Next
End If
nice solution, salad. there is a gap, though - the user could enter
something in the combo box and exit the control, then go back and remove the
value and again exit the control. at that point, all the other controls are
still unlocked. how about modifying your code a little, to remove the outer
If statement, as
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
ctl.Locked = IsNull(Me.Combo 0)
End If
Next
hth
"salad" <oi*@vinegar.co m> wrote in message
news:Oh******** *******@newsrea d2.news.pas.ear thlink.net... Ap******@gmail. com wrote: Hello
I have a single form, and want to require the user to make a selection from a serialnumber ComboBox before being allowed to enter any other textboxes. Also, the user should be allowed to click on an Exit button I created and get a response.
The following code works fine without the ExitButton issue:
Private Sub SerialCombo_Exi t(Cancel As Integer) Dim Ctl As Control If IsNull(SerDevCo mbo) Then MsgBox "You must enter a serial#" Me.AnyOtherFiel d.SetFocus 'acts as a refresh Me.SerialCombo. SetFocus 'return to field since it is empty End If End Sub
MY PROBLEM IS INCLUDING THE CHECK FOR a change of focus when clicking on the ExitButton. I tried many different methods.
If Not (Screen.ActiveC ontrol.Name <> "ExitButton ") Then
ThankYou I created a combo box and a command button to close/exit. Here's the code for my combo using the OnExit method.
Private Sub Combo0_Exit(Can cel As Integer) If IsNull(Me.Combo 0) Then Cancel = True MsgBox "Select an item" End If End Sub
This works...except if I press the X button to close the window.
Now if you wanted to allow the person to exit even if the serial no is null, what you could set, in design mode, all of the textbox controls to Enabled = True/Locked = True. This permits only the combo to be updated or exit button to be pressed.
In the AfterUpdate event for the combo you could do something like If Not IsNull(Me.Combo 0) Then Dim ctl As Control For Each ctl In Me.Controls If ctl.ControlType = acTextBox Then ctl.Locked = False Endif Next End If
tina wrote: nice solution, salad. there is a gap, though - the user could enter something in the combo box and exit the control, then go back and remove the value and again exit the control. at that point, all the other controls are still unlocked. how about modifying your code a little, to remove the outer If statement, as
Dim ctl As Control
For Each ctl In Me.Controls If ctl.ControlType = acTextBox Then ctl.Locked = IsNull(Me.Combo 0) End If Next
hth
Much better.
This solution still does not meet the OP's requirements !!
<< before being allowed to enter any other textboxes>>
The user can still enter any other textbox and he probably will become
confused because he can not enter data in the textbox. The solution that
meets the OP's requirements is:
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
ctl.Locked = IsNull(Me.Combo 0)
ctl.Enabled = Not IsNull(Me.Combo 0)
End If
Next
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
Over 1175 users have come to me from the newsgroups requesting help re******@pcdata sheet.com
"salad" <oi*@vinegar.co m> wrote in message
news:Wy******** *******@newsrea d2.news.pas.ear thlink.net... tina wrote:
nice solution, salad. there is a gap, though - the user could enter something in the combo box and exit the control, then go back and remove the value and again exit the control. at that point, all the other controls are still unlocked. how about modifying your code a little, to remove the outer If statement, as
Dim ctl As Control
For Each ctl In Me.Controls If ctl.ControlType = acTextBox Then ctl.Locked = IsNull(Me.Combo 0) End If Next
hth Much better.
"PC D" <fa***@email.co m> schreef in bericht news:WR******** *********@newsr ead1.news.atl.e arthlink.net... PC Datasheet Your Resource For Help With Access, Excel And Word Applications 'Resource ???? Over 1175 users have come to me from the newsgroups requesting help '1175 users ???? re******@pcdata sheet.com
--
To Steve:
Why PC D this time? Why not PCD anymore, or Access Resource or Help available or why not just PC DataSheet?
You think that changing names is vital for you?
Why don't you just get lost? No-one wants your advertising/job hunting here!
Over 600!! users from the newsgroups have visited the website to read what kind of a 'resource' you are... (rapidly increasing..)
To the original poster:
Most people here have a common belief that the newsgroups are for *free exchange of information*.
But Steve is a notorious job hunter in these groups, always trying to sell his services.
Before you intend to do business with him look at: http://home.tiscali.nl/arracom/whoissteve.html
Arno R
well, considering that both salad and i suggested that the code be run in
the combo box control's AfterUpdate event - you're correct, it doesn't meet
the OP's requirements. there's nothing to stop the user from tabbing through
that control without making any changes, thus leaving the other controls
unlocked. but your revised code doesn't address that problem, either; it
simply enables/disables the other controls *again, only when the user first
makes a change in the combo box control*. disabling controls does nothing
more to make them unusable than simply locking them, though i'd agree with
you that it gives the user a visual cue that the controls unavailable.
i'd say that all three of us missed the boat here, to one degree or another.
the code i posted should be added to the form's Current event, in addition
to the combo box control's AfterUpdate event. that should take care of the
issue, unless i'm overlooking something - again.
hth
"PC D" <fa***@email.co m> wrote in message
news:WR******** *********@newsr ead1.news.atl.e arthlink.net... This solution still does not meet the OP's requirements !!
<< before being allowed to enter any other textboxes>>
The user can still enter any other textbox and he probably will become confused because he can not enter data in the textbox. The solution that meets the OP's requirements is:
Dim ctl As Control
For Each ctl In Me.Controls If ctl.ControlType = acTextBox Then ctl.Locked = IsNull(Me.Combo 0) ctl.Enabled = Not IsNull(Me.Combo 0) End If Next
-- PC Datasheet Your Resource For Help With Access, Excel And Word Applications Over 1175 users have come to me from the newsgroups requesting
help re******@pcdata sheet.com
"salad" <oi*@vinegar.co m> wrote in message news:Wy******** *******@newsrea d2.news.pas.ear thlink.net... tina wrote:
nice solution, salad. there is a gap, though - the user could enter something in the combo box and exit the control, then go back and
remove the value and again exit the control. at that point, all the other controls are still unlocked. how about modifying your code a little, to remove the outer If statement, as
Dim ctl As Control
For Each ctl In Me.Controls If ctl.ControlType = acTextBox Then ctl.Locked = IsNull(Me.Combo 0) End If Next
hth Much better.
I agree totally with your last comment Tina. Having the same concerns
and realizing that I would have had to alter a substantial number of
things in
my form to go your suggested route. I instead choose to repost an
alternate
idea. But it really surprised me that this idea would be so difficult
to implement.
Others have made suggestions, but I just can't seem to make it happen!
My alternate Post was:
If I am in a combobox, is there are way of determining which control
was clicked outside the combobox, before I actually leave the combobox?
yes, i've been following that thread too, Apex. and the answer is: AFAIK,
no. when you click, or tab, from one control to another, the events for the
first control (such as BeforeUpdate, AfterUpdate, and Exit) run before the
events for the second control (such as the second control). so the identity
of the "next" control isn't available at the time that the events of the
"current" control run.
my (and salad's) alternate solution, when presented in its' entirety, is
really simple enough. i'd suggest a private procedure in the form's module,
as
Private Sub isLocked()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
ctl.Locked = IsNull(Me.Combo 0)
End If
Next
End Sub
if you need to manage other controls such as combo boxes, beside the textbox
controls, you can add them to the If Statement, such as
If ctl.ControlType = acTextBox Or _
ct.ControlType = acComboBox Then
in the form's Current event, and the combo box's AfterUpdate event, simply
call the sub, as
isLocked
this is a pretty standard solution to the issue of managing controls on a
form based on a value in one of them. if it doesn't suit your needs, i'm
afraid i have no other suggestions to offer.
hth
<Ap******@gmail .com> wrote in message
news:11******** *************@i 39g2000cwa.goog legroups.com... I agree totally with your last comment Tina. Having the same concerns and realizing that I would have had to alter a substantial number of things in my form to go your suggested route. I instead choose to repost an alternate idea. But it really surprised me that this idea would be so difficult to implement. Others have made suggestions, but I just can't seem to make it happen!
My alternate Post was: If I am in a combobox, is there are way of determining which control was clicked outside the combobox, before I actually leave the combobox?
Tina
Thankyou for your help!
Greg This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Harlin Seritt |
last post by:
I've created a ghetto-ized ComboBox that should work nicely for Tkinter
(unfortunately no dropdown capabilities yet).
I've found why it's such a pain in the @ss to create one. You have to
re-create common methods and make sure they're mapped to the right
component (inside this widget are frame, entry, listbox, and scrollbar
widgets). I tried to look for ways I could inherit some methods from
other widgets but couldn't think of how to do...
|
by: Susan Bricker |
last post by:
The following error:
"The current field must match the join key '?' in the table that seves
as t the 'one' side of one-to-many relationship. Enter a record in the
'one' side table with the desired key value, and then make the entry
with the desired join key in the 'many-only' table."
... happens when I click on an entry of a combobox. HELP!!
Here's the background:
|
by: Susan Bricker |
last post by:
I went back to read my post and found an error in my description ...
here is the post, again, corrected:
The following error:
"The current field must match the join key '?' in the table that seves
as t the 'one' side of one-to-many relationship. Enter a record in the
'one' side table with the desired key value, and then make the entry
with the desired join key in the 'many-only' table."
|
by: Krul |
last post by:
I like to have a blank entry at top of the combobox list, so the user
is able to clear the combobox.
Right now, the form displays a empty entry on load, but after chosen a
value once, it is not possible to select a blank entry again. The only
way is to delete the string manually and press enter.
|
by: Tosch |
last post by:
I have a combobox where a user can select a zoom factor or enter a
zoom factor.
I tried to limit entry into the combobox to numbers only by catching
the keydown event and setting e.handled = true if any non number
characters are entered.
But those characters still appear in the combobox. Is this a combobox
bug?
If yes any workarounds?
Tosch
| |
by: peter78 |
last post by:
I wanted to implement an autocomplete feature on the combobox where you
would type in partial text and it would try to match it for you. It
doesn't exist in .Net yet, but I'm guessing it will in the next
version.
Here are instructions how to do it:
http://support.microsoft.com/default.aspx?scid=kb;en-us;320107
There is one bug, though.
|
by: Steve B. |
last post by:
Without adding whitespace to the ComboBox datasource is there a way I can add
a blank entry or, a reset entry, to the ComboBox dropdown
Thanks
Steve
|
by: tizmagik |
last post by:
I have a combobox on a continuous form that has a recordsource that is
set upon Form_Load event via VBA (based on initial form data and
external form data entered). For data entry purposes the Combobox's
value is saved to *another* field (text-field) in the appropriate table
(this text-field is not visible in the Continuous Form); so the
combobox is pretty much just for data-lookup purposes (so the user does
not have to type anything).
...
|
by: EManning |
last post by:
I have a combobox whose rowsource is a union query. This query
displays a person's name in "lastname, firstname" format and in
"firstname lastname" format. The query results look like this:
Mouse, Mickey
Mickey Mouse
When a person is added, the querys' underlying recordset is updated in
the NotInList event. I can't figure out how to refresh the combobox
to display the new person. I get the standard error message that the
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |