A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Conditional opening of field?



 
 
Thread Tools Display Modes
  #1  
Old September 18th, 2007, 07:22 PM posted to microsoft.public.access.tablesdbdesign
majahops
external usenet poster
 
Posts: 2
Default Conditional opening of field?

Hello, I have a quick (probably EASY) question. If anybody can answer this
for me, it would mean the WORLD to me.

I have a field in a table "Consent Form Returned?"... which I want to be by
default a check box -- with unchecked meaning no and checked meaning "yes".
However, upon being checked "yes", I'd like either that field to convert into
a date field or to unlock an adjacent "Return Date" field, where the date
that the form was returned can be entered.

Can anybody please tell me how to complete this simple task? Thank you so
much you have no idea how much I'd appreciate it. It's my birthday, it'd be
an awesome present

Thanks!

Tim

  #2  
Old September 18th, 2007, 07:40 PM posted to microsoft.public.access.tablesdbdesign
Jerry Whittle
external usenet poster
 
Posts: 4,732
Default Conditional opening of field?

It's not easy. In fact you can not do it in a table or query. Also you can't
convert a Yes/No field to a Date field.

Now the good news! You can do this in a form. Make your return date field
text box invisible and on the Yes/No check box do something on the On Update
event to make the Return Date text box visible again.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"majahops" wrote:

Hello, I have a quick (probably EASY) question. If anybody can answer this
for me, it would mean the WORLD to me.

I have a field in a table "Consent Form Returned?"... which I want to be by
default a check box -- with unchecked meaning no and checked meaning "yes".
However, upon being checked "yes", I'd like either that field to convert into
a date field or to unlock an adjacent "Return Date" field, where the date
that the form was returned can be entered.

Can anybody please tell me how to complete this simple task? Thank you so
much you have no idea how much I'd appreciate it. It's my birthday, it'd be
an awesome present

Thanks!

Tim


  #3  
Old September 18th, 2007, 07:51 PM posted to microsoft.public.access.tablesdbdesign
majahops
external usenet poster
 
Posts: 2
Default Conditional opening of field?

Thank you so much! You're gonna wanna beat me up here, but what would the
"something" I should write in "On Update" be - roughly? Thanks so much, I'll
understand if you haven't the time to answer.

Thanks again!

Tim

Jerry Whittle wrote:
It's not easy. In fact you can not do it in a table or query. Also you can't
convert a Yes/No field to a Date field.

Now the good news! You can do this in a form. Make your return date field
text box invisible and on the Yes/No check box do something on the On Update
event to make the Return Date text box visible again.
Hello, I have a quick (probably EASY) question. If anybody can answer this
for me, it would mean the WORLD to me.

[quoted text clipped - 12 lines]

Tim


  #4  
Old September 19th, 2007, 12:16 AM posted to microsoft.public.access.tablesdbdesign
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Conditional opening of field?

On Tue, 18 Sep 2007 18:22:43 GMT, "majahops" u37541@uwe wrote:

Hello, I have a quick (probably EASY) question. If anybody can answer this
for me, it would mean the WORLD to me.

I have a field in a table "Consent Form Returned?"... which I want to be by
default a check box -- with unchecked meaning no and checked meaning "yes".
However, upon being checked "yes", I'd like either that field to convert into
a date field or to unlock an adjacent "Return Date" field, where the date
that the form was returned can be entered.

Can anybody please tell me how to complete this simple task? Thank you so
much you have no idea how much I'd appreciate it. It's my birthday, it'd be
an awesome present

Thanks!

Tim


I hope Jerry doesn't mind my jumping in...

You would have a Form with a checkbox chkFormReturned (I'd suggest NOT using
spaces, question marks, or other special characters in fieldnames or control
names) bound to your yes/no field, and a separate textbox txtReturnDate. I'd
leave txtReturnDate's Visible property set to yes, but its Enabled property
set to No - it will be greyed out and will not allow editing.

Select chkFormReturned in form design view, and view its Properties. On the
Events tab find the AfterUpdate event; click the ... icon by it and select
"Code Builder". Access will put you into the VBA editor with a Sub and End Sub
line. Edit these to:

Private Sub chkFormReturned_AfterUpdate()
Me!txtReturnDate.Enabled = Me!chkFormReturned
End Sub

This will set the textbox's Enabled property to True if the checkbox is True,
False if it's not.

You'll also need to add the same line in the Form's Current event so that when
you move from record to record the control is enabled or disabled
appropriately.

John W. Vinson [MVP]
  #5  
Old September 19th, 2007, 04:52 PM posted to microsoft.public.access.tablesdbdesign
Jerry Whittle
external usenet poster
 
Posts: 4,732
Default Conditional opening of field?

Hi,

First create a form base on the table. You'll have to change the field names
below to what's in your form.

Second make the Locked property for the [Return Date] text box Yes. Do this
by right clicking on the text box while in design view. Bring up Properties
and go to the Data tab. You'll find Locked there.

Next right click on the [Returned] check box and bring up it's properties.
Go to the Event tab and select After Update. Next click on the Build button
(three dots on the right side) and select code builder.

In the VBA window between Private Sub OpenClose_AfterUpdate() and End Sub
put the following:

If Me.[Returned] = -1 Then
Me.[Return Date].Locked = False
Me.[Return Date] = Date()
End IF

Between OpenClose_AfterUpdate() and End Sub put the following:

If Me.[Returned] = -1 Then
Me.[Return Date].Locked = False
Else
Me.[Return Date].Locked = True
End If

Go up to Debug, Compile and make sure you don't get an error. Next Save and
close the VBA window.

Go back to the form and save it. Then open the form in Form View and test,
test, test.

You might want to do all this in a copy of the database and them import the
form into production once you are sure that it works as you wish.

--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"majahops" wrote:

Thank you so much! You're gonna wanna beat me up here, but what would the
"something" I should write in "On Update" be - roughly? Thanks so much, I'll
understand if you haven't the time to answer.

Thanks again!

Tim

Jerry Whittle wrote:
It's not easy. In fact you can not do it in a table or query. Also you can't
convert a Yes/No field to a Date field.

Now the good news! You can do this in a form. Make your return date field
text box invisible and on the Yes/No check box do something on the On Update
event to make the Return Date text box visible again.
Hello, I have a quick (probably EASY) question. If anybody can answer this
for me, it would mean the WORLD to me.

[quoted text clipped - 12 lines]

Tim



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:16 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.