473,830 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Contingent formatting

Problem:

When moving between records, I need to control which combo/text boxes
are displayed on the current form, dependent upon data in the current
record.

More:

I building my first access database.

Record entry is by a single form, and the form contains many cases of
contingent combo boxes, text boxes, etc.

When building the form, I was testing only the form by itself for a
single record, not moving between records. Everything works fine so
long as you do not move between records.

However, when I move between records, the formatting (ie. which
combo/text boxes are visible/enabled) remains as it was on the most
recent manually entered record.

A simple way to address this would be to have an 'OnChangeRecord ' type
event which detects presses on the MS Access default record controls
which appear at the bottom left of the screen. Is this possible? If so,
how?

For my form formatting, I have used the _Change event for combo boxes.
Where should this formatting go, and where does it need to be to update
correctly whenever a user moves between records?

I have experimented with the Form_AfterUpdat e event without success.
Any help greatly appreciated.

Dec 21 '05 #1
12 2369
The Current event of the form fires whenever the user moves record.

The Change event of a combo fires for every keystroke, so use its
AfterUpdate event to respond to a change in value.

If you have lots of controls that need to be hidden/shown, you probably need
a different data structure, where some of the attributes you are saving
become values in a related table rather than fields of the one big table.

You cannot conditionally hide columns if your form is in Continuous or
Datasheet view.

--
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.

"dmieluk" <dm*****@exemai l.com.au> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
Problem:

When moving between records, I need to control which combo/text boxes
are displayed on the current form, dependent upon data in the current
record.

More:

I building my first access database.

Record entry is by a single form, and the form contains many cases of
contingent combo boxes, text boxes, etc.

When building the form, I was testing only the form by itself for a
single record, not moving between records. Everything works fine so
long as you do not move between records.

However, when I move between records, the formatting (ie. which
combo/text boxes are visible/enabled) remains as it was on the most
recent manually entered record.

A simple way to address this would be to have an 'OnChangeRecord ' type
event which detects presses on the MS Access default record controls
which appear at the bottom left of the screen. Is this possible? If so,
how?

For my form formatting, I have used the _Change event for combo boxes.
Where should this formatting go, and where does it need to be to update
correctly whenever a user moves between records?

I have experimented with the Form_AfterUpdat e event without success.
Any help greatly appreciated.

Dec 21 '05 #2
Thank you for your quick reply.
The Current event of the form fires whenever the user moves record.


In form view, Access provides default record selection buttons. Is the
Current event supposed to fire when the user changes record using these
buttons? I added this code to my form:

Private Sub Form_Current()

Beep

End Sub

I do not hear the beep when I change records using the provided
buttons.

By contrast, I do hear the beep when I add the beep command to one of
my existing combo box Change events (when I change that combo box).

Dec 21 '05 #3
Yes: Form_Current fires with the built-in nav. buttons.

Replace
beep
with
Debug.Print "Changed record at " & Now()

Open the Immediate Window (Ctrl+G) and watch the output.

--
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.

"dmieluk" <dm*****@exemai l.com.au> wrote in message
news:11******** *************@o 13g2000cwo.goog legroups.com...
Thank you for your quick reply.
The Current event of the form fires whenever the user moves record.


In form view, Access provides default record selection buttons. Is the
Current event supposed to fire when the user changes record using these
buttons? I added this code to my form:

Private Sub Form_Current()

Beep

End Sub

I do not hear the beep when I change records using the provided
buttons.

By contrast, I do hear the beep when I add the beep command to one of
my existing combo box Change events (when I change that combo box).

Dec 21 '05 #4
Hmmm.

I'll be as explicit as I can because this is starting to get strange.

I altered the code as said, and opened the Immediate window.

I saved the code, opened the form and went to form view.

I used the default Nav buttons to move between records, and also edited
a few records, and created a new record.

There was no entry in the immediate window.

Then, I added the Debug code(Debug.Prin t "Changed record at " & Now())
into one of my combo box change events. I returned to form view, used
the combo box, and the immediate window subsequently had an entry
(Changed record at 21/12/2005 2:44:42 PM).

I am using Windows XP with MS Access 2000.

The form code is exactly:

Private Sub Form_Current()

Debug.Print "Changed record at " & Now()

End Sub

and this procedure is in the same place where all the form events are
placed by default (Indeed, the event was created automatically using
the drop down menus).

Perplexed.

Dec 21 '05 #5
Allen already answered most everything, and so here are my 2cents as
well. :)
To show or hide specific controls based on the record you are showing I
usually do it this way.
In the properties for the controls you will see one called Tag. For
all the controls you want to disable, put in a word that signifies
something to do with why you are disabling these controls - for this
example, we'll use the word Employed. I don't know what you are
looking for that will signal to the form to hide records, but just for
the sake of explanation, lets say you have a field called Employed and
it's either true or false.
Now in your foms OnCurrent event
dim ctlDisable as control
for each ctlDisable in me.controls
If ctlDisable.tag= "Employed" then ctlDisabled.ena bled=me!Employe d
next
Anyway I hope that helps you

Dec 21 '05 #6
Presumably this is a bound form, because the built-in nav buttons would not
do anything in an unbound form.

If Form_Current is not firing, the database is partially corrupt. Follow
this sequence until you start seeing the debug.print working.

1. Uncheck the boxes under:
Tools | Options | General | Name AutoCorrect
Explanation of why:
http://allenbrowne.com/bug-03.html

2. Compact the database to get rid of this junk:
Tools | Database Utilities | Compact

3. Close Access. Make a backup copy of the file. Decompile the database by
entering something like this at the command prompt while Access is not
running. It is all one line, and include the quotes:
"c:\Program Files\Microsoft office\office\m saccess.exe" /decompile
"c:\MyPath\MyDa tabase.mdb"

4. Open Access, and compact again.

5. Open a code window.
Choose References from the Tools menu.
Uncheck any references you do not need.
For a list of the ones you typically need in your version of Access, see:
http://allenbrowne.com/ser-38.html

6. Still in the code window, choose Compile from the Debug menu.
Fix any errors, and repeat until it compiles okay.

At this point, you should have a database where the name-autocorrect errors
are gone, the indexes are repaired, inconsistencies between the text- and
compiled-versions of the code are fixed, and reference ambiguities are
resolved.

If it is still a problem, the next step would be to get Access to rebuild
the database for you. Follow the steps for the first symptom in this
article:
Recovering from Corruption
at:
http://allenbrowne.com/ser-47.html

--
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.

"dmieluk" <dm*****@exemai l.com.au> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
Hmmm.

I'll be as explicit as I can because this is starting to get strange.

I altered the code as said, and opened the Immediate window.

I saved the code, opened the form and went to form view.

I used the default Nav buttons to move between records, and also edited
a few records, and created a new record.

There was no entry in the immediate window.

Then, I added the Debug code(Debug.Prin t "Changed record at " & Now())
into one of my combo box change events. I returned to form view, used
the combo box, and the immediate window subsequently had an entry
(Changed record at 21/12/2005 2:44:42 PM).

I am using Windows XP with MS Access 2000.

The form code is exactly:

Private Sub Form_Current()

Debug.Print "Changed record at " & Now()

End Sub

and this procedure is in the same place where all the form events are
placed by default (Indeed, the event was created automatically using
the drop down menus).

Perplexed.

Dec 21 '05 #7
Thanks for your help Allen.

I follow through this carefully and see if I can get it going.

Dec 21 '05 #8
On 20 Dec 2005 19:48:20 -0800, "dmieluk" <dm*****@exemai l.com.au>
wrote:

This could be a case of "event procedure not connected to event".
Proceed as follows:
Bring form in design view
Show form-level properties
Select Events, and click the ... button next to the Current event.
Observe that the code window opens, with your Beep code or Debug.Print
code.
Close all and test again.
If it works now, then the above has reconnected the event procedure to
the event. No corruption was ever there.

-Tom.

Hmmm.

I'll be as explicit as I can because this is starting to get strange.

I altered the code as said, and opened the Immediate window.

I saved the code, opened the form and went to form view.

I used the default Nav buttons to move between records, and also edited
a few records, and created a new record.

There was no entry in the immediate window.

Then, I added the Debug code(Debug.Prin t "Changed record at " & Now())
into one of my combo box change events. I returned to form view, used
the combo box, and the immediate window subsequently had an entry
(Changed record at 21/12/2005 2:44:42 PM).

I am using Windows XP with MS Access 2000.

The form code is exactly:

Private Sub Form_Current()

Debug.Print "Changed record at " & Now()

End Sub

and this procedure is in the same place where all the form events are
placed by default (Indeed, the event was created automatically using
the drop down menus).

Perplexed.


Dec 21 '05 #9
On 20 Dec 2005 19:48:20 -0800, "dmieluk" <dm*****@exemai l.com.au> wrote:

and this procedure is in the same place where all the form events are
placed by default (Indeed, the event was created automatically using
the drop down menus).

Perplexed.


Open the Property Sheet for the form and click the Event tab.
In the text box next to On Current make sure that it has [Event Procedure] entered.

Code against each event will not fire unless this property is set. It sounds like your form may not have this property
set.

If you create a procedure in the VBE window directly (by using the drop down menus), this property is not set
automatically and you must enter [Event Procedure] in the property sheet against the related event before the code will
fire.

To set the property automatically you must initiate the code creation from the property sheet.
In the property sheet, click in the Event you wish to create. An elipse? button (...) will appear to the extreme left of
the property. Click this button and select Event Procedure. The VBE window will open with procedure header and footer
created, and [Event Procedure] will be entered in the property sheet automatically.
Wayne Gillespie
Gosford NSW Australia
Dec 21 '05 #10

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

Similar topics

3
5942
by: Jouke Langhout | last post by:
Hello all! For quite some time now, I've got the following problem: Access won't close properly when a user closes the application. An ACCESS process stays active and that process can only be terminated by pressing ++ and then terminate the process. I searched the entire internet and found out that there could be two things wrong (both of them are mentioned in the bug list on the access
2
1950
by: Colleyville Alan | last post by:
I am using Access and have embedded the ActiveX control Formula One that came with Office 2000. (ver 3.04). I have created and formatted a spreadsheet and now I want to copy the info with formatting to another program. The help file reads: "Formula One maintains its own internal clipboard and also supports text on the Windows clipboard. The internal clipboard is more flexible than the Windows clipboard. The internal clipboard...
4
4166
by: DBQueen | last post by:
I have a subform which is in Continuous Forms view. I have added a button to the bottom of the page to move to the next record using the button wizard (result: DoCmd.GoToRecord , , acNext). I want all of the controls in whatever is the CURRENT record to have it's data bolded on the screen. (Question #1: Is there a SIMPLE way to refer to the Current Record?) I've been trying to use a Bookmark to specify the current record, but it
4
3149
by: Bradley | last post by:
I have an A2000 database in which I have a continuous form with a tick box. There is also a text box with a conditional format that is based on the expression , if it's true then change the background colour. In A2000 it works great, but in A2003 the background doesn't always change and when it does it only changes when the record looses the focus. Any way around this? Is it a bug? Or have they "improved" it?
4
3240
by: hope | last post by:
Hi, How can I format a string field using Data Formatting Expression property in datagrid? For example: format last name from BROWN to Brown. Thanks
7
3120
by: L. Scott M. | last post by:
Have a quick simple question: dim x as string x = "1234567890" ------------------------------------------------------- VB 6 dim y as string
8
1781
by: gopal | last post by:
Hi I am trying to write to log file but the formatting of string is not properly aligned in log file result The results looks some thing like this OK move.xml Successful OK AppUser_ifrUsers.asp Successful
8
8521
by: Typehigh | last post by:
I have many text fields with conditional formatting applied, specifically when the condition is "Field Has Focus". Without any events associated with the fields the conditional formatting works perfectly. However, I have code that runs under the ON CLICK event. The code changes the focus to other controls, which means the conditional formatting is no longer displayed. This part makes sense to me. Here's what doesn't make sense. The last...
6
1656
by: BUmed | last post by:
Hi all I’m trying to figure this out. But help is needed. I have a combo box called fcmFLAG with 5 options (problem, hold off, call, withdrew and ineligible). What I would like to do is have the background in a memo box (fcmFcom) change to a different color for each option. I don’t think this can be done with Conditional formatting because it’s more then 3. The problem is that I just started getting into VBA but I have been using Access for...
0
9777
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, 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...
0
9635
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10763
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, 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...
0
10473
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9307
agi2029
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...
0
6939
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();...
0
5772
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4407
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
3
3070
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.