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 Programming / January 2008

Tip: Looking for answers? Try searching our database.

Save control data

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dee - 30 Jan 2008 20:03 GMT
From this newsgroup, I was very happy to be able to enable or disable
controls on my form, depending upon whether there was data already entered in
the control.  It works very well:
Private Sub Form_Current()
'if cbo_ppt_no control(and any other) has already been selected, lock it;
otherwise leave it unlocked
       Me.cbo_ppt_no.Locked = Not IsNull(Me.cbo_ppt_no)
       Me.cbo_qstnaire_id.Locked = Not IsNull(Me.cbo_qstnaire_id)
End Sub

What I have noticed, however, is that even when I've populated this control,
it isn't until I navigate to another record that it becomes locked.  Is there
a way to make this happen as soon as I populate the control and move on to
another control?  I have made a few attempts, but they don't work.

Any help would be greatly appreciated!
Signature

Thanks!

Dee

Marshall Barton - 30 Jan 2008 20:46 GMT
>From this newsgroup, I was very happy to be able to enable or disable
>controls on my form, depending upon whether there was data already entered in
[quoted text clipped - 10 lines]
>a way to make this happen as soon as I populate the control and move on to
>another control?  I have made a few attempts, but they don't work.

Use the appropriate line of code in each of the controls'
AfterUpdate event.

Signature

Marsh
MVP [MS Access]

dee - 30 Jan 2008 20:57 GMT
Thanks for your response.

I actually did try to add code to the individual control's AfterUpdate
event, but wasn't successful.

Would  you have any advice on what the code should be?
Signature

Thanks!

Dee

> >From this newsgroup, I was very happy to be able to enable or disable
> >controls on my form, depending upon whether there was data already entered in
[quoted text clipped - 13 lines]
> Use the appropriate line of code in each of the controls'
> AfterUpdate event.
Marshall Barton - 30 Jan 2008 21:53 GMT
>Thanks for your response.
>
>I actually did try to add code to the individual control's AfterUpdate
>event, but wasn't successful.
>
>Would  you have any advice on what the code should be?

The code should be exactly the same as what you used in the
Current event, except that you only need the one appropriate
line for for each control.  E.g.

Private Sub cbo_ppt_no_AfterUPdate()
    Me.cbo_ppt_no.Locked = Not IsNull(Me.cbo_ppt_no)
End Sub

Signature

Marsh
MVP [MS Access]

dee - 30 Jan 2008 21:24 GMT
On another note, I am now having problems using the code when I have a
default of, say the text LU at the beginning of the control.  In other words,
if the control contains only 2 letters, then don't lock.

I have tried this in my On Current form event - the first line works fine -
the second not at all:
       Me.box_no.Locked = Not IsNull(Me.box_no)
   
       Me.txt_ppt_no.Locked = Not Len(Me.txt_ppt_no) = 2

Help! :-)
Signature

Thanks!

Dee

> >From this newsgroup, I was very happy to be able to enable or disable
> >controls on my form, depending upon whether there was data already entered in
[quoted text clipped - 13 lines]
> Use the appropriate line of code in each of the controls'
> AfterUpdate event.
Marshall Barton - 30 Jan 2008 22:03 GMT
>On another note, I am now having problems using the code when I have a
>default of, say the text LU at the beginning of the control.  In other words,
[quoted text clipped - 5 lines]
>    
>        Me.txt_ppt_no.Locked = Not Len(Me.txt_ppt_no) = 2

This should do that:

Me.txt_ppt_no.Locked = Len(Nz(Me.txt_ppt_no, "XX") <> 2

If that's too cryptic, an equivalent, but longer, statement
is:

Me.txt_ppt_no.Locked = Len(Me.txt_ppt_no) <> 2 _
                                                And Not IsNull(Me.txt_ppt_no)

Signature

Marsh
MVP [MS Access]

 
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.