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 / May 2005

Tip: Looking for answers? Try searching our database.

Coding Clarification Please

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MarcTA - 29 Apr 2005 15:40 GMT
I submitted the below question in a forum and received the below answer.  Can
anyone give me clarification on the code.  I think it is Visual Basic, which
I know nothing about, and have not been able to get the code to work.  I
keeps giving me errors.

<How can I Auto enter current time into one field when "completed" is
selected
from a different combobox.

I am making a form that I want to have a "date finalized" automaticaly
entered when I move the status combobox to "completed".  I would also like to
be able to lock that form from being edited.  Is this possible and How?

Thanks,

Use the AfterUpdate event for the list box:

if me.MyList="Completed" then
       me.MyTimeField = now()
end if

To lock the form use the Current event on the form:

if me.Mylist="Completed" then
    if me.allowedits then
          me.allowedits=false
    end if
else
    if not me.allowedits then  ' unlocks the form when is not completed
status
          me.allowedits=edit
    end if
end if
jl5000

Thanks for the responce!
However, I am confused with your syntax.  Admitedly I am not a programer.
The form name is "ID#" and the comboBox is named "Status".  The Time box is
named "DateFinalized".

If willing, would you give me the syntax.  I tried a few different ways but
I always get a syntax error.

Thanks,

MarcTA

I also received this:

See my answer in your other (subject-only) message for the first.

For the latter, you'll need to set the Form's AllowEdits property to
False in the AfterUpdate event of the combo box, if the value is
"Completed". You will *also* need to put code in the Form's Current
event to check the value of the status field, and set the form's
AllowEdits to True or False appropriately.

                 John W. Vinson[MVP]    

Thanks,

MarcTA
jl5000 - 01 May 2005 22:53 GMT
That is Visual Basic,

To implement the code:
1.Open your form in design view.
2.Select the combo box.
3.Select properties from the view menu.
4.Click on the Event tab in the properties window.
5.In the After Update event select [Event Procedure]
6.Click on the builder (...) button of the after update
7.Paste the code startin on the if and ending on end if (similar to the one
I provided previously) into the visual basic window that opened in step 6. It
should look like:

Private Sub Status_AfterUpdate()
    if me.Status="Completed" then
          me.DateFinalized= now()
    end if
End Sub

8.Close the Visual Basic window.
9.For the On Current event, click on the upper left corner on the design
view of the form to see the properties of the form.
10.On the On Current event select [Event Procedure]
11.Click on the Builder (...) button.
12.Paste the code starting on the first if and ending on the las end if, it
should look like this:

Private Sub Form_Current()
 if me.Status="Completed" then
     if me.allowedits then
           me.allowedits=false
     end if
else
     if not me.allowedits then  
           me.allowedits=edit
     end if
end if
end sub

> I submitted the below question in a forum and received the below answer.  Can
> anyone give me clarification on the code.  I think it is Visual Basic, which
[quoted text clipped - 58 lines]
>
> MarcTA
MarcTA - 03 May 2005 14:00 GMT
Thanks for the step-by-step.  The DateFinalized code works very well.
However, the Lock for code works too well.  The form I use it on contains
multiple subforms, and I need to go back and forth between that two at will.  
When I start a new form everything works until I click on a subform and then
back to the main form, then the form locks, no matter what is in in the
Status combo box.  The combobox options are  "Assigned";"InProgress";"Sent
for Review";"Completed" and a Null value.  Is there a way to keep the form
unlocked until the "Completed" is chosen.  Also, once the "Completed" is
chosen and I scroll to the next record that is not "Completed" that the form
unlocks.

> That is Visual Basic,
>
[quoted text clipped - 97 lines]
> >
> > MarcTA
jl5000 - 05 May 2005 21:16 GMT
The on Current eventy should read

     me.allowedits=True
instead of
     me.allowedits=edit

Signature

jl5000
<a href="http://joshdev.com"></a>

> Thanks for the step-by-step.  The DateFinalized code works very well.
> However, the Lock for code works too well.  The form I use it on contains
[quoted text clipped - 108 lines]
> > >
> > > MarcTA
MarcTA - 05 May 2005 22:23 GMT
Thanks,
That works great for the main form.  Do you know a way to lock the subforms
as well?

Thanks again,

~MarcTA

> The on Current eventy should read
>
[quoted text clipped - 114 lines]
> > > >
> > > > MarcTA
jl5000 - 11 May 2005 03:39 GMT
if not me.mysubform.locked then
    me.mysubform.locked=true
end if

Signature

jl5000
<a href="http://www.joshdev.com"></a>

> Thanks,
> That works great for the main form.  Do you know a way to lock the subforms
[quoted text clipped - 122 lines]
> > > > >
> > > > > MarcTA
 
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.