473,503 Members | 5,004 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Disabling part of a form on startup and setting the focus

I borrowed one of the forms from the MS Access Solutions database and
altered it to fit my needs. The form was the 'EditProducts' form where you
select a category from a combo which then populates another combo for
products. Then when you select a product, the form displays the info for it.
Everything is working well except, with the original, when the form is
opened, the focus is on the SelectCategory combo box, while the form
elements are greyed out until you select a category and product. When I open
my form, the main form is active, and the focus is on one of those controls.
Once I select an item from the first combo box in the header, then the form
controls grey out until I select a option from the second combo. I am at my
wits end trying to figure out what I've missed. I've posed the code for the
form below.

Option Compare Database
Option Explicit

Private Sub Form_AfterUpdate()

' Requery SelectProduct combo box.
Me!SelectProject.Requery
End Sub

Private Sub SelectClient_AfterUpdate()

' Enable and requery SelectProduct combo box.
' Disable controls in detail section.

Me!SelectProject.Enabled = True
Me!SelectProject.Requery
EnableControls Me, acDetail, False
End Sub

Private Sub SelectProject_AfterUpdate()

' Find record for product selected in SelectProduct combo box.
' Enable controls in detail section and disable ProductID text box.
' Go to SupplierID combo box.

DoCmd.ApplyFilter , "ProjectID = Forms!frmWorksheet!SelectProject"
EnableControls Me, acDetail, True
Me!ProjectID.Enabled = False
Me!ProjectLocation.SetFocus
End Sub

Private Sub SelectProject_BeforeUpdate(Cancel As Integer)
If IsNull([SelectProject]) Then
MsgBox "You must select a project."
Cancel = True
End If

End Sub
May 13 '06 #1
1 2182
In the Load event procedure of the form, SetFocus to the combo, and call the
code tha disables the contorls in the Detail section:
Me.SelectProject.SetFocus
EnableControls Me, acDetail, False

We don't know what the EnableControls sub does, but that should work if the
SelectProject combo is not in the Detail section.

(If the form returns no records, and no new records can be added, Access
could have problems.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Robert" <no**@email.com> wrote in message
news:Pm*******************@fe01.news.easynews.com. ..
I borrowed one of the forms from the MS Access Solutions database and
altered it to fit my needs. The form was the 'EditProducts' form where you
select a category from a combo which then populates another combo for
products. Then when you select a product, the form displays the info for
it. Everything is working well except, with the original, when the form is
opened, the focus is on the SelectCategory combo box, while the form
elements are greyed out until you select a category and product. When I
open my form, the main form is active, and the focus is on one of those
controls. Once I select an item from the first combo box in the header,
then the form controls grey out until I select a option from the second
combo. I am at my wits end trying to figure out what I've missed. I've
posed the code for the form below.

Option Compare Database
Option Explicit

Private Sub Form_AfterUpdate()

' Requery SelectProduct combo box.
Me!SelectProject.Requery
End Sub

Private Sub SelectClient_AfterUpdate()

' Enable and requery SelectProduct combo box.
' Disable controls in detail section.

Me!SelectProject.Enabled = True
Me!SelectProject.Requery
EnableControls Me, acDetail, False
End Sub

Private Sub SelectProject_AfterUpdate()

' Find record for product selected in SelectProduct combo box.
' Enable controls in detail section and disable ProductID text box.
' Go to SupplierID combo box.

DoCmd.ApplyFilter , "ProjectID = Forms!frmWorksheet!SelectProject"
EnableControls Me, acDetail, True
Me!ProjectID.Enabled = False
Me!ProjectLocation.SetFocus
End Sub

Private Sub SelectProject_BeforeUpdate(Cancel As Integer)
If IsNull([SelectProject]) Then
MsgBox "You must select a project."
Cancel = True
End If

End Sub

May 13 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
5031
by: Lyn | last post by:
Hi, I hope someone can help. I have a main form which mostly fills the Access window. In the bottom half of this form I have a tab control to display various types of data related to the main...
11
9088
by: Pete | last post by:
Is there any way to change the default search to "Any Part Of Field" instead of whole field? The first thing I ever do when searching for something in a field is change the default setting from...
6
5819
by: Ekim | last post by:
hy, I've got a quite simple application: one windows form that consists of a button, and as soon as the user hits the button a second form shall appear. The difficult thing about it is that I...
1
1411
by: David Hearn | last post by:
I have a javascript function that is fired on the KeyDown event of a textbox. I am adding the attribute to the textbox at page load to run this javascript function. The javascript runs as expected...
0
1393
by: Stephen Muecke | last post by:
The startup form of my application is used to open other forms containing detail information on projects, organisations, employees etc (similar to Outlook) Each detail form has a print method...
1
2779
by: kebabkongen | last post by:
Hi, I'm working on a JavaScript that is enabling / disabling a select element according to whether a checkbox is selected or not. This works fine in Firefox, but in Internet Explorer (v 6.0.2900)...
11
2204
by: shankwheat | last post by:
I have a function which passes text from txtdebt to debtsbox which works fine. However, I want to add code which examines the value of debtsbox and if any of the values the user entered contain the...
2
5158
by: Robert McEuen | last post by:
Access 97/2003 Windows XP (Classic Start Menu) I just converted an mdb from A97 to A2K3 and found something that, after Google search, doesn't appear to have been addressed in cdma... I have...
1
1617
by: Semajthewise | last post by:
Here it is cleaned up a little more. Here's what this code does. It will take 2 fractions and add, subtract, multiply, or divide them. The user enters the fractions to be calculated into two...
0
7188
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
7063
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
7258
Oralloy
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,...
0
7313
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...
1
6970
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7441
tracyyun
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...
0
4663
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...
0
3146
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
366
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.