changing cntrl props in continuous view for 'active' record in A2K

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

Guest

i have a cmd button on my sub-form which i want to enable when the value of a
listbox control called "Continuing" is "Yes". if "Continuing" is "No", the
cmd btn (called "Duplicate") should be disabled.

my vba on the "Continuing" is:

Private Sub Continuing_AfterUpdate()
Me.Duplicate.Enabled = False
If Me.Continuing.Value = "Yes" Then Me.Duplicate.Enabled = True
End Sub

and if works fine.

since changing the property of the "Duplicate" button has the effect of
displaying the change on every instance of the form's in the user's view
(since it's a continous form we're using and not a single form), it looks
funny to see the button's property seem to change for those records that are
not impicated, i.e. other than the current record's.

i should add at this point that the underlying table has a pk consisting of
5 controls and that i created five unbound txt controls which i dropped into
the sub-form's header section called txtCurKey1,....,txtCurKey5.

now, i have written some vba which compiles and does not seem to yet do what
i want (see below):

Private Sub Form_Current()
Dim txtCurKey1 As Long, txtCurKey2 As Integer, txtCurKey3 As String,
txtCurKey4 As String, txtCurKey5 As Date
txtCurKey1 = Me.Patient_Number
txtCurKey2 = Me.Cycle
txtCurKey3 = Me.AE_Description
txtCurKey4 = Me.Subtype
txtCurKey5 = Me.Onset
If txtCurKey1 = Me.Patient_Number And txtCurKey2 = Me.Cycle And txtCurKey3 =
Me.AE_Description And _
txtCurKey4 = Me.Subtype And txtCurKey5 = Me.Onset And Me.Continuing =
"Yes" Then
Me.Duplicate.Enabled = True
ElseIf txtCurKey1 = Me.Patient_Number And txtCurKey2 = Me.Cycle And
txtCurKey3 = Me.AE_Description _
And txtCurKey4 = Me.Subtype And txtCurKey5 = Me.Onset And Me.Continuing =
"No" Then Me.Duplicate.Enabled = False
ElseIf Not (txtCurKey1 = Me.Patient_Number And txtCurKey2 = Me.Cycle And
txtCurKey3 = Me.AE_Description And _
txtCurKey4 = Me.Subtype And txtCurKey5 = Me.Onset) And Me.Continuing =
"Yes" Then Me.Duplicate.Enabled = True
ElseIf Not (txtCurKey1 = Me.Patient_Number And txtCurKey2 = Me.Cycle And
txtCurKey3 = Me.AE_Description _
And txtCurKey4 = Me.Subtype And txtCurKey5 = Me.Onset) And Me.Continuing
= "No" Then Me.Duplicate.Enabled = False
' Me.Duplicate.Enabled = True
End If
'If Me.Continuing.Value = "Yes" Then Me.Duplicate.Enabled = True
End Sub

my goal is to get a2k to know when to display "Duplicate" as enabled; i
think that it'd look 'good' to the user to see that when "Continuing" is
"Yes" whether or not he's 'on' a record that the "Duplicate" button is
enabled. conversely, that it'd somehow be 'good' for the user to see that the
"Duplicate" button is disabled when the "Continuing" field was a "No" whether
or not......
and to have the "enabled" property of the "Duplicate" cmdbtn able to get
switched at will when the user's 'on' a record.

anyone out there see the achilees' heel in this?

thanks for the bandwidth.
 
You can not do that with a command button in the detail
section of a continuous form. I like to place the command
button in the subform's Header or Footer section where there
will only be one instance of the button. Since the button
applies only to the current record, there is no confusion.
 
you are johnny on the spot, marshall!!

this makes excellent sense (force of habit got the better of yours truly
there for a ny minute, i guess).

what about the code vba part?

ted

Marshall Barton said:
You can not do that with a command button in the detail
section of a continuous form. I like to place the command
button in the subform's Header or Footer section where there
will only be one instance of the button. Since the button
applies only to the current record, there is no confusion.
--
Marsh
MVP [MS Access]


i have a cmd button on my sub-form which i want to enable when the value of a
listbox control called "Continuing" is "Yes". if "Continuing" is "No", the
cmd btn (called "Duplicate") should be disabled.

my vba on the "Continuing" is:

Private Sub Continuing_AfterUpdate()
Me.Duplicate.Enabled = False
If Me.Continuing.Value = "Yes" Then Me.Duplicate.Enabled = True
End Sub

and if works fine.

since changing the property of the "Duplicate" button has the effect of
displaying the change on every instance of the form's in the user's view
(since it's a continous form we're using and not a single form), it looks
funny to see the button's property seem to change for those records that are
not impicated, i.e. other than the current record's.

i should add at this point that the underlying table has a pk consisting of
5 controls and that i created five unbound txt controls which i dropped into
the sub-form's header section called txtCurKey1,....,txtCurKey5.

now, i have written some vba which compiles and does not seem to yet do what
i want (see below):

Private Sub Form_Current()
Dim txtCurKey1 As Long, txtCurKey2 As Integer, txtCurKey3 As String,
txtCurKey4 As String, txtCurKey5 As Date
txtCurKey1 = Me.Patient_Number
txtCurKey2 = Me.Cycle
txtCurKey3 = Me.AE_Description
txtCurKey4 = Me.Subtype
txtCurKey5 = Me.Onset
If txtCurKey1 = Me.Patient_Number And txtCurKey2 = Me.Cycle And txtCurKey3 =
Me.AE_Description And _
txtCurKey4 = Me.Subtype And txtCurKey5 = Me.Onset And Me.Continuing =
"Yes" Then
Me.Duplicate.Enabled = True
ElseIf txtCurKey1 = Me.Patient_Number And txtCurKey2 = Me.Cycle And
txtCurKey3 = Me.AE_Description _
And txtCurKey4 = Me.Subtype And txtCurKey5 = Me.Onset And Me.Continuing =
"No" Then Me.Duplicate.Enabled = False
ElseIf Not (txtCurKey1 = Me.Patient_Number And txtCurKey2 = Me.Cycle And
txtCurKey3 = Me.AE_Description And _
txtCurKey4 = Me.Subtype And txtCurKey5 = Me.Onset) And Me.Continuing =
"Yes" Then Me.Duplicate.Enabled = True
ElseIf Not (txtCurKey1 = Me.Patient_Number And txtCurKey2 = Me.Cycle And
txtCurKey3 = Me.AE_Description _
And txtCurKey4 = Me.Subtype And txtCurKey5 = Me.Onset) And Me.Continuing
= "No" Then Me.Duplicate.Enabled = False
' Me.Duplicate.Enabled = True
End If
'If Me.Continuing.Value = "Yes" Then Me.Duplicate.Enabled = True
End Sub

my goal is to get a2k to know when to display "Duplicate" as enabled; i
think that it'd look 'good' to the user to see that when "Continuing" is
"Yes" whether or not he's 'on' a record that the "Duplicate" button is
enabled. conversely, that it'd somehow be 'good' for the user to see that the
"Duplicate" button is disabled when the "Continuing" field was a "No" whether
or not......
and to have the "enabled" property of the "Duplicate" cmdbtn able to get
switched at will when the user's 'on' a record.

anyone out there see the achilees' heel in this?

thanks for the bandwidth.
 
I couldn't unravel all that code. It looked like you set a
bunch of variables to the values of the key fields and then
compared them to check if they have the value just assigned
to them???

From your description, I think all you need is to use the
statement:

Me.Duplicate.Enabled = (Me.Continuing.Value = "Yes")

in both the form's Current event and the Continuing
control's AfterUpdate event.
 
looks like parsimony rules :-)

i must've been "stuck in past" of the datasheet view days.

i look forward to implementing this and want to express my thanks for the
generous bandwidth.

best,

ted

Marshall Barton said:
I couldn't unravel all that code. It looked like you set a
bunch of variables to the values of the key fields and then
compared them to check if they have the value just assigned
to them???

From your description, I think all you need is to use the
statement:

Me.Duplicate.Enabled = (Me.Continuing.Value = "Yes")

in both the form's Current event and the Continuing
control's AfterUpdate event.
--
Marsh
MVP [MS Access]


you are johnny on the spot, marshall!!

this makes excellent sense (force of habit got the better of yours truly
there for a ny minute, i guess).

what about the code vba part?
 
Back
Top