Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / December 2005

Tip: Looking for answers? Try searching our database.

On Change Bug?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ivan R - 29 Dec 2005 20:27 GMT
Okay I have a form whose caption is based on some information on the form.
The information updates the caption at every change.  For example the caption
at a new record will read "Background Analysis Database", however when there
is information entered for a specific record, the database will change the
caption to "Background Check for LastName, FirstName Middlename".  My problem
or bug appears when I start to change the FirstName field.  There is code
behind the fields that will automatically update the caption at each change
for the field, however on the FirstName field when you first enter the first
change, the first letter is selected and over written, the user then has to
go back over and retype the first letter or it causes them to be off by one
letter.  The code I have entered in the background goes as follows, and it is
entered in the On Change event:

DoCmd.RunCommand acCmdSaveRecord
UpdateCaption

UpdateCaption is a small module which saves me some typing it goes like this:

Dim fstname, lstname, midname, Name As String
fstname = Forms![main form]![applicant firstname]
lstname = Forms![main form]![Applicant LastName]
midname = Forms![main form]![Applicant MiddleName]
Name = lstname & ", " & fstname & " " & midname
Me.Caption = "Background Check for " & Name

Any help or suggestions would be appreciated.
Jeff Boyce - 29 Dec 2005 23:39 GMT
Ivan

I don't know if it will make a difference in what you are seeing, but...

The word "Name" is a reserved word in Access.  You are using it in your
code.  Access may be confused as to just what you are referring to.  Try
changing that to PersonName...

Regards

Jeff Boyce
<Office/Access MVP>

> Okay I have a form whose caption is based on some information on the form.
> The information updates the caption at every change.  For example the
[quoted text clipped - 31 lines]
>
> Any help or suggestions would be appreciated.
Ivan R - 30 Dec 2005 14:31 GMT
Thansk Jeff.

I changed the Name variable to wholeName, however it is still exhibiting this
odd behaviour.  If you have any other suggestions I would like to hear them.

>Ivan
>
[quoted text clipped - 14 lines]
>>
>> Any help or suggestions would be appreciated.
Larry Linson - 29 Dec 2005 23:49 GMT
The OnChange event fires for every keystroke of the Control. I really doubt
that is the event to which you want to respond. I suspect you really want to
change the caption only when you have all three, First/Middle/Last names
entered. I am also not sure I can see a "business purpose" for changing the
caption, unless you are likely to have multiple copies of the same form
open, and some minimized. The caption isn't really a very convenient place
to have changeable data.

But, assuming there is a reason to change the caption, my suggestion would
be to call the same procedure from the AfterUpdate event of each of the name
fields, check that all three have been entered, and then execute the code
you show.  Assuming you'll be using the same or similar form to edit the
records, put the code in the Current event, as well, so the caption will
reflect the person whose data is being edited, as well.

 Larry Linson
 Microsoft Access MVP

> Okay I have a form whose caption is based on some information on the form.
> The information updates the caption at every change.  For example the
[quoted text clipped - 31 lines]
>
> Any help or suggestions would be appreciated.
Ivan R - 30 Dec 2005 14:39 GMT
The only reason that i will not use the code on the afterupdate event is that
I want the name in the caption to change as the user types the information
into the database, if I do it in the afterupdate event it will not make the
change until the record is complete or you add a new record.  I did try the
code there first, it just didn't have the effect that I wanted and the whole
reason for doing this on this event is the effect, which is the changing of
the name as you go.  I know it is probably not really a pressing and urgent
issue, but I think it is a cool effect and if it all possible I would like to
keep it...

The code right now is in the CurrentEvent of the form and on the OnChange
event of the fields that are used to change the caption.

>The OnChange event fires for every keystroke of the Control. I really doubt
>that is the event to which you want to respond. I suspect you really want to
[quoted text clipped - 19 lines]
>>
>> Any help or suggestions would be appreciated.
Larry Linson - 31 Dec 2005 05:17 GMT
As was pointed out more politely by others -- however "cool" you may think
the effect, changing the caption of the form is, at best, an "unusual and
unfamiliar" interface feature -- there are other, simpler,
less-disturbing-to-the-user approaches to showing what record is being
edited. One of those would be to display the information in large
characaters in the Form's Header... the information could be displayed in a
Label or a Text Box.

Please note that I suggested the AfterUpdate event of the Control into which
you are typing, not the Form's AfterUpdate, if you feel compelled to submit
your users to the unfamiliar UI. The Record is not, at least not
necessarily, saved before the Control's AfterUpdate.

Just for the record: my clients always wanted to insulate their users from
"unusual and unfamiliar" interface features, because they had to figure out
what was going on, and it caused a negative impact to their employees'
productivity.

Larry Linson
Microsoft Access MVP

> The only reason that i will not use the code on the afterupdate event is
> that
[quoted text clipped - 44 lines]
>>>
>>> Any help or suggestions would be appreciated.
Ivan R - 31 Dec 2005 16:52 GMT
Thank you,

I will keep this in mind.  I had not thought about adding the information to
the form header, you are right that is a good spot to put important
information.

Thanks

>As was pointed out more politely by others -- however "cool" you may think
>the effect, changing the caption of the form is, at best, an "unusual and
[quoted text clipped - 22 lines]
>>>>
>>>> Any help or suggestions would be appreciated.
John Vinson - 30 Dec 2005 02:13 GMT
>Me.Caption = "Background Check for " & Name
>
>Any help or suggestions would be appreciated.

I'd suggest not using the caption property AT ALL: instead, put a
textbox on the form with a Control Source of the concatenation
expression.

                 John W. Vinson[MVP]    
Dirk Goldgar - 30 Dec 2005 05:38 GMT
> Okay I have a form whose caption is based on some information on the
> form. The information updates the caption at every change.  For
[quoted text clipped - 12 lines]
> DoCmd.RunCommand acCmdSaveRecord
> UpdateCaption

I really don't think you want to save the record every time the user
types a new letter in the text box.  That may be causing the odd
selection behavior you're seeing, and it doesn't really make sense
anyway.

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Ivan R - 30 Dec 2005 14:44 GMT
I tried it without saving the record and if it is not included, then the
caption is not updated at  every stroke.  The odd behavior also is only on
the first letter entered, once the record is created I can go back delete
everything and start all over without the behaviour at all.  Do you think
that it could be an issue with the record being created?  I have some code
that is executed the minute that the record is created.  It then causes the
form to repaint...I think this is my problem, huh?

>> Okay I have a form whose caption is based on some information on the
>> form. The information updates the caption at every change.  For
[quoted text clipped - 6 lines]
>selection behavior you're seeing, and it doesn't really make sense
>anyway.
Ivan R - 30 Dec 2005 15:10 GMT
I have found out what my problem was.  I had some code in the PK field which
repainted the form on change from null to the next number.  The second that
the user typed a letter into any field, which spawned a change in the primary
key, the form was repainted, causing the selection of the first field with
any data entered, in this instance the first letter of the first name field.
I figured that I did not need the code on the primary key field and so I
changed it to the afterupdate event of the first field, now it works great!

>I tried it without saving the record and if it is not included, then the
>caption is not updated at  every stroke.  The odd behavior also is only on
[quoted text clipped - 9 lines]
>>selection behavior you're seeing, and it doesn't really make sense
>>anyway.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.