Am I wrong?

Am I wrong?

am 30.11.2007 15:26:02 von maceslin

I have frmMinutes with all fields diabled on load except for an option
group that I use to toggle on the correct fields depending on option
chosen. Each choice works as designed but if I switch back and forth
between the two the fields do not go on and off as I thought they
would (ie, the user made a mistkae and ralizes he shouild be using the
other format)

Have included the code below

Private Sub Form_Load()

TitleOfReport.Enabled = False
EventStartDate.Enabled = False
EventEndDate.Enabled = False
KeyAttendees.Enabled = False
PurposeOfTrip.Enabled = False
cboPurposeCodes.Enabled = False
Discussions.Enabled = False
Conclusions.Enabled = False
Location.Enabled = False
MeetingChair.Enabled = False
OldBusiness.Enabled = False
NewBusiness.Enabled = False
cboNIOCLead.Enabled = False


End Sub

Private Sub grpFormatChoice_AfterUpdate()
'select fields for meeting
If grpFormatChoice.Value = 2 Then
TitleOfReport.Enabled = True
EventStartDate.Enabled = True
KeyAttendees.Enabled = True
PurposeOfTrip.Enabled = True
Discussions.Enabled = True
Conclusions.Enabled = True
Location.Enabled = True
MeetingChair.Enabled = True
OldBusiness.Enabled = True
NewBusiness.Enabled = True
cboNIOCLead.Enabled = True
End If
' select fields for Trip report
If grpFormatChoice.Value = 1 Then
TitleOfReport.Enabled = True
EventStartDate.Enabled = True
KeyAttendees.Enabled = True
PurposeOfTrip.Enabled = True
Discussions.Enabled = True
Conclusions.Enabled = True
Location.Enabled = True
MeetingChair.Enabled = True
OldBusiness.Enabled = True
NewBusiness.Enabled = True
cboNIOCLead.Enabled = True
cboPurposeCodes.Enabled = True
EventEndDate.Enabled = True

End If

End Sub

Thanks for looking
Dave

Re: Am I wrong?

am 30.11.2007 15:53:12 von Salad

maceslin@gmail.com wrote:

> I have frmMinutes with all fields diabled on load except for an option
> group that I use to toggle on the correct fields depending on option
> chosen. Each choice works as designed but if I switch back and forth
> between the two the fields do not go on and off as I thought they
> would (ie, the user made a mistkae and ralizes he shouild be using the
> other format)
>
> Have included the code below
>
> Private Sub Form_Load()
>
> TitleOfReport.Enabled = False
> EventStartDate.Enabled = False
> EventEndDate.Enabled = False
> KeyAttendees.Enabled = False
> PurposeOfTrip.Enabled = False
> cboPurposeCodes.Enabled = False
> Discussions.Enabled = False
> Conclusions.Enabled = False
> Location.Enabled = False
> MeetingChair.Enabled = False
> OldBusiness.Enabled = False
> NewBusiness.Enabled = False
> cboNIOCLead.Enabled = False
>
>
> End Sub
>
> Private Sub grpFormatChoice_AfterUpdate()
> 'select fields for meeting
> If grpFormatChoice.Value = 2 Then
> TitleOfReport.Enabled = True
> EventStartDate.Enabled = True
> KeyAttendees.Enabled = True
> PurposeOfTrip.Enabled = True
> Discussions.Enabled = True
> Conclusions.Enabled = True
> Location.Enabled = True
> MeetingChair.Enabled = True
> OldBusiness.Enabled = True
> NewBusiness.Enabled = True
> cboNIOCLead.Enabled = True
> End If
> ' select fields for Trip report
> If grpFormatChoice.Value = 1 Then
> TitleOfReport.Enabled = True
> EventStartDate.Enabled = True
> KeyAttendees.Enabled = True
> PurposeOfTrip.Enabled = True
> Discussions.Enabled = True
> Conclusions.Enabled = True
> Location.Enabled = True
> MeetingChair.Enabled = True
> OldBusiness.Enabled = True
> NewBusiness.Enabled = True
> cboNIOCLead.Enabled = True
> cboPurposeCodes.Enabled = True
> EventEndDate.Enabled = True
>
> End If
>
> End Sub
>
> Thanks for looking
> Dave

Well, it appears you are doing it incorrectly if you ever want your code
to disable some of the controls

Here's a suggestion.
Open your form in design mode. Set the Enabled value to No for all of
the fields. Then remove the OnLoad code. It's not necessary....unless
you can skip from record to record. Then move it to another event like
the OnCurrent event.

Next, some of your fields are going to be enabled whether or not the
value is 1 or 2. So simply do something like this

Private Sub grpFormatChoice_AfterUpdate()
'select fields for meeting
TitleOfReport.Enabled = True
EventStartDate.Enabled = True
KeyAttendees.Enabled = True

The above fields will alway be enabled whether 1 or 2. Now there are
some fields that are to be enabled or disabled. You can use code like this
EventEndDate.Enabled = (grpFormatChoice.Value = 1)
as this field is to be enabled if 1 but disabled if 2. The
(grpFormatChoice.Value = 1)
will return either True or False. There is really no need to have
If/Endif statements depending on grpFormatChoice. So we end up with

Private Sub grpFormatChoice_AfterUpdate()
'select fields for meeting
TitleOfReport.Enabled = True
EventStartDate.Enabled = True
KeyAttendees.Enabled = True
...your other controls
EventEndDate.Enabled = (grpFormatChoice.Value = 1)

TGIF
http://www.youtube.com/watch?v=cUxWZxD3MPw

Re: Am I wrong?

am 30.11.2007 15:53:52 von Ron2006

Once the field is enabled, it will stay enabled until it is disabled
or until you exit the form and return so that the default is re-
established.

Your test should be:

If grpFormatChoice.Value = 2 Then
ENABLE THE CHOICE 2 FIELDS
and disable the CHOICE 1 fields
endif
If grpFormatChoice.Value = 1 Then
ENABLE THE CHOICE 1 FIELDS
and disable the CHOICE 2 fields
endif


Ron

Re: Am I wrong?

am 30.11.2007 17:18:47 von Ron2006

Another thought that you need to consider:

If the user selects choice 1 and puts information into 3 of the
fields and then realizes that he should have selected choice 2 and
does so, what about the partially (or even fully) filed out fiels for
choice 1. You now have inconsistent information.

You may want to empty the fields along with making them disabled.
OR
on each condition check first for data in the opposing fields and not
alow the change until the user has cleared them out or ask if you
really wants to do this since there is information in the fields.

Ron

Re: Am I wrong?

am 03.12.2007 01:35:54 von maceslin

On Nov 30, 11:18 am, Ron2006 wrote:
> Another thought that you need to consider:
>
> If the user selects choice 1 and puts information into 3 of the
> fields and then realizes that he should have selected choice 2 and
> does so, what about the partially (or even fully) filed out fiels for
> choice 1. You now have inconsistent information.
>
> You may want to empty the fields along with making them disabled.
> OR
> on each condition check first for data in the opposing fields and not
> alow the change until the user has cleared them out or ask if you
> really wants to do this since there is information in the fields.
>
> Ron

Ron and Salad

Sorry no response sooner but been away for weekend. Thanks for
advice, it all makes sense and I will implement at work tomm

Thanks