How can I find the first blank control on a form by looking at the controls
in the order of their tab order?
Thanks!
Tom 5 2954
Tom put this code in a button on your form.
I tested it, would place the cursor on the first empty text box.
Dim ctl As Control
Dim vIndex As Long
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
With ctl
If IsNull(Me.Controls.Item(vIndex)) = True Then
MsgBox vIndex & ": " & Me.Controls.Item(vIndex).Name & " Value: "
& Me.Controls.Item(vIndex)
Me.Controls.Item(vIndex).SetFocus
Exit Sub
End If
End With
End If
'This is used to track the actual Item Number.
vIndex = vIndex + 1
Next ctl
Regards
Barry
"Tom" <ts******@nospam.please> wrote in message
news:8A****************@newsread3.news.pas.earthli nk.net... How can I find the first blank control on a form by looking at the controls in the order of their tab order?
Thanks!
Tom
On Thu, 06 Jan 2005 22:02:44 GMT, "Tom" <ts******@nospam.please> wrote: How can I find the first blank control on a form by looking at the controls in the order of their tab order?
Something like this:
1) Decide which types of control you're interested in. E.g. Labels and
Lines don't have a TabIndex property, and blank commandbuttons may or
may not be of interest.
2) For each type you're interested in, decide what you mean by "blank"
(e.g. Null, False, zero-length string?) What about subform controls?
3) Iterate through all the controls on the form.
For Each ctlC in Me.Controls
If ctlC.Type is one you interested in Then
store its Name and TabIndex in a structure or collection
End If
Next
Iterate through the stored control names in TabIndex order
Check the type of the control, apply your rule for
whether it's blank (e.g. for a textbox,
IsNull(Me.Controls(strCtlName).Value)
Stop at the first blank control or at the end of the form
--
John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.
Thanks, John!
I was still wondering how to get the controls in tab order. Where can I find
a list of the constants for each type of control?
Tom
"John Nurick" <j.*************@dial.pipex.com> wrote in message
news:84********************************@4ax.com... On Thu, 06 Jan 2005 22:02:44 GMT, "Tom" <ts******@nospam.please> wrote:
How can I find the first blank control on a form by looking at the
controlsin the order of their tab order?
Something like this:
1) Decide which types of control you're interested in. E.g. Labels and Lines don't have a TabIndex property, and blank commandbuttons may or may not be of interest.
2) For each type you're interested in, decide what you mean by "blank" (e.g. Null, False, zero-length string?) What about subform controls?
3) Iterate through all the controls on the form. For Each ctlC in Me.Controls If ctlC.Type is one you interested in Then store its Name and TabIndex in a structure or collection End If Next Iterate through the stored control names in TabIndex order Check the type of the control, apply your rule for whether it's blank (e.g. for a textbox, IsNull(Me.Controls(strCtlName).Value) Stop at the first blank control or at the end of the form -- John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.
Tom,
For the constants, look up ControlType in the Object Browser.
One way of getting them in tab order is along these lines:
Dim colC As New VBA.Collection
Dim j as Long
Dim lngHighestTabIndex As Long
...
lngHighestTabIndex = 0
'store relevant names and tab indexes in collection
For Each ctlC in Me.Controls
With ctlC
Select Case .Type
Case acBlah, acSomething, acSomethingElse...
colC.Add ctlC.Name, Format(.TabIndex, "000")
If .TabIndex > lngHighestTabIndex Then
lngHighestTabIndex = .TabIndex
End If
End Select
Next 'ctlC
'Iterate through the stored control names in TabIndex order
On Error Resume Next
For j = 1 To lngHighestTabIndex
strCtlName = colC.Item(Format(j, "000"))
If Err.Number = 0 Then
If [control is blank] Then
Exit For
End If
End If
Err.Clear
Next j
On Error GoTo 0
On Fri, 07 Jan 2005 16:51:11 GMT, "Tom" <ts******@nospam.please> wrote: Thanks, John!
I was still wondering how to get the controls in tab order. Where can I find a list of the constants for each type of control?
Tom "John Nurick" <j.*************@dial.pipex.com> wrote in message news:84********************************@4ax.com.. . On Thu, 06 Jan 2005 22:02:44 GMT, "Tom" <ts******@nospam.please> wrote:
>How can I find the first blank control on a form by looking at thecontrols >in the order of their tab order?
Something like this:
1) Decide which types of control you're interested in. E.g. Labels and Lines don't have a TabIndex property, and blank commandbuttons may or may not be of interest.
2) For each type you're interested in, decide what you mean by "blank" (e.g. Null, False, zero-length string?) What about subform controls?
3) Iterate through all the controls on the form. For Each ctlC in Me.Controls If ctlC.Type is one you interested in Then store its Name and TabIndex in a structure or collection End If Next Iterate through the stored control names in TabIndex order Check the type of the control, apply your rule for whether it's blank (e.g. for a textbox, IsNull(Me.Controls(strCtlName).Value) Stop at the first blank control or at the end of the form -- John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.
--
John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.
Thanks, John, for all your help especially the code here!
Tom
"John Nurick" <j.*************@dial.pipex.com> wrote in message
news:77********************************@4ax.com... Tom,
For the constants, look up ControlType in the Object Browser.
One way of getting them in tab order is along these lines:
Dim colC As New VBA.Collection Dim j as Long Dim lngHighestTabIndex As Long ... lngHighestTabIndex = 0
'store relevant names and tab indexes in collection For Each ctlC in Me.Controls With ctlC Select Case .Type Case acBlah, acSomething, acSomethingElse... colC.Add ctlC.Name, Format(.TabIndex, "000") If .TabIndex > lngHighestTabIndex Then lngHighestTabIndex = .TabIndex End If End Select Next 'ctlC
'Iterate through the stored control names in TabIndex order On Error Resume Next For j = 1 To lngHighestTabIndex strCtlName = colC.Item(Format(j, "000")) If Err.Number = 0 Then If [control is blank] Then Exit For End If End If Err.Clear Next j On Error GoTo 0 On Fri, 07 Jan 2005 16:51:11 GMT, "Tom" <ts******@nospam.please> wrote:
Thanks, John!
I was still wondering how to get the controls in tab order. Where can I
finda list of the constants for each type of control?
Tom "John Nurick" <j.*************@dial.pipex.com> wrote in message news:84********************************@4ax.com.. . On Thu, 06 Jan 2005 22:02:44 GMT, "Tom" <ts******@nospam.please> wrote:
>How can I find the first blank control on a form by looking at the controls >in the order of their tab order?
Something like this:
1) Decide which types of control you're interested in. E.g. Labels and Lines don't have a TabIndex property, and blank commandbuttons may or may not be of interest.
2) For each type you're interested in, decide what you mean by "blank" (e.g. Null, False, zero-length string?) What about subform controls?
3) Iterate through all the controls on the form. For Each ctlC in Me.Controls If ctlC.Type is one you interested in Then store its Name and TabIndex in a structure or collection End If Next Iterate through the stored control names in TabIndex order Check the type of the control, apply your rule for whether it's blank (e.g. for a textbox, IsNull(Me.Controls(strCtlName).Value) Stop at the first blank control or at the end of the form -- John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.
-- John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Tim Eliot |
last post by:
Just wondering if anyone has hit the following issue and how you might
have sorted it out.
I am using the command:
DoCmd.TransferText acExportMerge, , stDataSource, stFileName, True
after...
|
by: MX1 |
last post by:
Hi,
I have a report with Name1 and Name2 in the address section . Sometimes,
Name2 is not populated with data via the query that feeds the report.
Unfortunately, the blank line stays in the...
|
by: jquest |
last post by:
Hi Again;
I have had help from this group before and want to thank everyone,
especially PCDatasheet.
My database includes a field called HomePhone, it uses the (xxx)xxx-xxx
format to include...
|
by: Todd |
last post by:
I am somewhat new to ASP.NET and I am probably overlooking some basic
rule that's causing my error. Anyways, here's the scoop: I am using
a DataReader to access a SQL stored procedure. I want...
|
by: Dan |
last post by:
Hi,
I'd like to find out the control that caused a postback to be raised. Obviously this could simply done in a control event handler. I am not going to do this method and would like no...
|
by: TdarTdar |
last post by:
HI,
I have a asp 2.0 page that has a sqldatasource and a detailsview i have
enabled the inserting updating deleting in the datasoure. I have a blank
table that has no records. I run the page.. I...
|
by: Evan M. |
last post by:
Here's my GridView and my SqlDataSource
<asp:GridView ID="ContactHistoryGrid" runat="server"
AutoGenerateColumns="False" DataSourceID="ContactHistoryDS"
DataKeyNames="JobHistoryID"...
|
by: mlwerth |
last post by:
Dear Access Group:
This is the most basic and most embarrassing of questions, but I
cannot find where to change the data type of a text field that I have
in Access 2003 to a number field. I've...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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...
|
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,...
|
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...
| |