Coding Clarification Please

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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

jl5000 said:
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


MarcTA said:
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
 
The on Current eventy should read

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



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


MarcTA said:
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.

jl5000 said:
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


MarcTA said:
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
 
Thanks,
That works great for the main form. Do you know a way to lock the subforms
as well?

Thanks again,

~MarcTA

jl5000 said:
The on Current eventy should read

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



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


MarcTA said:
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.

jl5000 said:
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
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
 
if not me.mysubform.locked then
me.mysubform.locked=true
end if


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


MarcTA said:
Thanks,
That works great for the main form. Do you know a way to lock the subforms
as well?

Thanks again,

~MarcTA

jl5000 said:
The on Current eventy should read

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



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


MarcTA said:
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,

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
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
 
Back
Top