chkobsolete_afterUpdate() change

S

Sondra

Until I can normalize the data in my tables, I need to use
this command on my form:

Private Sub chkobsolete_AfterUpdate()
If Me.chkObsolete Then
For Each ctl in Me.Controls
If Left(ctl.Name, 9) = "togBinder" Then
ctl = 0
End If
Next
End If
End Sub

But I have two miscellaneous togglebuttons on my form that
are needing to be marked as yes when the obsolete button
is checked. I tried to write it how I thought it would be
written, but need some advise. Can you help me with
defining the rest of the code for this:

Private Sub chkobsolete_AfterUpdate()
If Me.chkObsolete Then
For Each ctl in Me.Controls
If Left(ctl.Name, 9) = "togBinder" Then
ctl = 0
If Left(ct1.Name, 10) = "miscBinder" Then
ctl = 1
End If
Next
End If
End Sub

I am currently working on normalizing my data in the new
database that I'm writing for this project. Thanks in
advance.

Sondra
 
D

Dirk Goldgar

Sondra said:
Until I can normalize the data in my tables, I need to use
this command on my form:

Private Sub chkobsolete_AfterUpdate()
If Me.chkObsolete Then
For Each ctl in Me.Controls
If Left(ctl.Name, 9) = "togBinder" Then
ctl = 0
End If
Next
End If
End Sub

But I have two miscellaneous togglebuttons on my form that
are needing to be marked as yes when the obsolete button
is checked. I tried to write it how I thought it would be
written, but need some advise. Can you help me with
defining the rest of the code for this:

Private Sub chkobsolete_AfterUpdate()
If Me.chkObsolete Then
For Each ctl in Me.Controls
If Left(ctl.Name, 9) = "togBinder" Then
ctl = 0
If Left(ct1.Name, 10) = "miscBinder" Then
ctl = 1
End If
Next
End If
End Sub

I am currently working on normalizing my data in the new
database that I'm writing for this project. Thanks in
advance.

Sondra

There's a syntax error in your code. Also, setting your toggle buttons
to "yes" probably means setting them to -1, or the equivalent constant
True. See if this works for you:

'----- start of revised code -----
Private Sub chkobsolete_AfterUpdate()

If Me.chkObsolete Then

For Each ctl in Me.Controls

If Left(ctl.Name, 9) = "togBinder" Then
ctl = False
ElseIf Left(ctl.Name, 10) = "miscBinder" Then
ctl = True
End If

Next ctl

End If

End Sub

'----- end of revised code -----
 
S

Somdra

-----Original Message-----


There's a syntax error in your code. Also, setting your toggle buttons
to "yes" probably means setting them to -1, or the equivalent constant
True. See if this works for you:

'----- start of revised code -----
Private Sub chkobsolete_AfterUpdate()

If Me.chkObsolete Then

For Each ctl in Me.Controls

If Left(ctl.Name, 9) = "togBinder" Then
ctl = False
ElseIf Left(ctl.Name, 10) = "miscBinder" Then
ctl = True
End If

Next ctl

End If

End Sub

'----- end of revised code -----

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
This isn't working for me. Please help.

I've verified that all my toggle buttons are named
correctly. I've verified that the function is on the
AfterUpdate event.

Nothing Happens!

Can you tell me what "ctl" is in the function and also if
you might know why its not working?

Thanks.
 
D

Dirk Goldgar

[I wrote:]
This isn't working for me. Please help.

I've verified that all my toggle buttons are named
correctly. I've verified that the function is on the
AfterUpdate event.

Nothing Happens!

Nothing happens? But the original code worked, so far as it went? Are
you sure you copied the code exactly? Do none of the buttons get set or
cleared properly, or is it just the "miscBinder" buttons that aren't
working?

Are these controls members of option groups, or standalone controls?
Toggle buttons that are members of option groups don't have values of
their own -- only the option group's value can be set. I've been
assuming that these are standalone controls, or the code could not have
worked before. I suppose it could be that the "togBinder" controls are
standalone, and the "miscBinder" controls are members of an option
group. Then those latter buttons wouldn't work.
Can you tell me what "ctl" is in the function and also if
you might know why its not working?

"ctl" is a temporary hold variable that is set in turn to each control
on the form. As for why it's not working, in the absence of an error
message we have a lot of investigating to do. One thing to do is set a
breakpoint on the procedure to see if it gets called at all.
 
S

Sondra

-----Original Message-----
[I wrote:]
This isn't working for me. Please help.

I've verified that all my toggle buttons are named
correctly. I've verified that the function is on the
AfterUpdate event.

Nothing Happens!

Nothing happens? But the original code worked, so far as it went? Are
you sure you copied the code exactly? Do none of the buttons get set or
cleared properly, or is it just the "miscBinder" buttons that aren't
working?
Toggle buttons that are members of option groups don't
have values of
their own -- only the option group's value can be set. I've been
assuming that these are standalone controls, or the code could not have
worked before. I suppose it could be that the "togBinder" controls are
standalone, and the "miscBinder" controls are members of an option
group. Then those latter buttons wouldn't work.
Can you tell me what "ctl" is in the function and also if
you might know why its not working?

"ctl" is a temporary hold variable that is set in turn to each control
on the form. As for why it's not working, in the absence of an error
message we have a lot of investigating to do. One thing to do is set a
breakpoint on the procedure to see if it gets called at all.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
Are these controls members of option groups, or standalone
controls?

The options are standalone.

But the original code worked, so far as it went?

Not working at all!

Are you sure you copied the code exactly?

The only diference was that I changed the name of the
binders from "togbinder" to "db*" and "miscbinder" to "ob*"

*=binder Number

I changed the ctl.Name, 9 to ct.Name, 2

Do none of the buttons get set or cleared properly, or is
it just the "miscBinder" buttons that aren't working?

No checks are being adjusted to yes or no, true or false,
or 0 or -1.

I was hoping to have this working so I could begin
normalizing and move everything by week end next week.

Would the fact that there are 42 checkboxes on the form
affect this? I know NORMALIZE!!!

Thanks for all your help. As I'm just beginning to
understand a great deal of this.
 
D

Dirk Goldgar

Sondra said:
The options are standalone.


Not working at all!

I know it's not working now, but I was under the impression that you
were starting from code that was actually working, and then modifying
it -- and the modifications didn't work. So I didn't investigate
certain possibilities.
The only diference was that I changed the name of the
binders from "togbinder" to "db*" and "miscbinder" to "ob*"

*=binder Number

I changed the ctl.Name, 9 to ct.Name, 2


No checks are being adjusted to yes or no, true or false,
or 0 or -1.

You're going to have to copy and paste the actual code, as it is now,
into a message, so I can see what you're really trying to execute.
Errors creep in every time you re-type something.

Also, please try compiling your project using the menu items Debug ->
Compile. If any error messages are displayed, please report them.

Did you do what I said, and set a breakpoint in the code to see if it
gets called at all? Make sure that the After Update property for the
control "chkobsolete" -- on the Event tab of the control's property
sheet -- is set to "[Event Procedure]".
 
G

Guest

Dirk:

Sorry our system went down and I couldn't get back to this
until now.

Here is the code as I currently have it written. I have
run step the function with no error messages

Private Sub Obsolete_AfterUpdate()
If Me.Obsolete Then

For Each ctl In Me.Controls

If Left(ctl.Name, 2) = "db" Then
ctl = no
ElseIf Left(ctl.Name, 2) = "ob" Then
ctl = yes
End If

Next ctl
End If
End Sub

-----Original Message-----
The options are standalone.


Not working at all!

I know it's not working now, but I was under the impression that you
were starting from code that was actually working, and then modifying
it -- and the modifications didn't work. So I didn't investigate
certain possibilities.
The only diference was that I changed the name of the
binders from "togbinder" to "db*" and "miscbinder" to "ob*"

*=binder Number

I changed the ctl.Name, 9 to ct.Name, 2


No checks are being adjusted to yes or no, true or false,
or 0 or -1.

You're going to have to copy and paste the actual code, as it is now,
into a message, so I can see what you're really trying to execute.
Errors creep in every time you re-type something.

Also, please try compiling your project using the menu items Debug ->
Compile. If any error messages are displayed, please report them.

Did you do what I said, and set a breakpoint in the code to see if it
gets called at all? Make sure that the After Update property for the
control "chkobsolete" -- on the Event tab of the control's property
sheet -- is set to "[Event Procedure]".

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


.
 
D

Dirk Goldgar

Dirk:

Sorry our system went down and I couldn't get back to this
until now.

Here is the code as I currently have it written. I have
run step the function with no error messages

Private Sub Obsolete_AfterUpdate()
If Me.Obsolete Then

For Each ctl In Me.Controls

If Left(ctl.Name, 2) = "db" Then
ctl = no
ElseIf Left(ctl.Name, 2) = "ob" Then
ctl = yes
End If

Next ctl
End If
End Sub

That's not the code I suggested. Why did you change my use of the
defined constants False and True to the meaningless (as far as VB is
concerned "no" and "yes"? Have you somewhere defined these as variables
or constants? If not, then I guess you don't have Option Explicit
(meaning "require variable declarations") set for your module, and it's
accepting them as undefined Variant variables with a value of Null.

I note also that you appear to have changed the name of the control from
"chkObsolete" to just "Obsolete". Is that right? If so, just revise
the above code as follows:

'----- start of revisedcode -----
Private Sub Obsolete_AfterUpdate()

Dim ctl As Control

If Me.Obsolete Then

For Each ctl In Me.Controls

If Left(ctl.Name, 2) = "db" Then
ctl = False
ElseIf Left(ctl.Name, 2) = "ob" Then
ctl = True
End If

Next ctl

End If

End Sub
'----- end of code -----
 
S

Sondra

-----Original Message-----


That's not the code I suggested. Why did you change my use of the
defined constants False and True to the meaningless (as far as VB is
concerned "no" and "yes"? Have you somewhere defined these as variables
or constants? If not, then I guess you don't have Option Explicit
(meaning "require variable declarations") set for your module, and it's
accepting them as undefined Variant variables with a value of Null.

I note also that you appear to have changed the name of the control from
"chkObsolete" to just "Obsolete". Is that right? If so, just revise
the above code as follows:

'----- start of revisedcode -----
Private Sub Obsolete_AfterUpdate()

Dim ctl As Control

If Me.Obsolete Then

For Each ctl In Me.Controls

If Left(ctl.Name, 2) = "db" Then
ctl = False
ElseIf Left(ctl.Name, 2) = "ob" Then
ctl = True
End If

Next ctl

End If

End Sub
'----- end of code -----

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


.
This now works. When it wasn't working is when I
tried "yes" "no" "0" and "-1".

I have something more that I want to see if it is possible:

Can I define the function even more to say if:

db currently = true then when chkobsolete is checked
db=false and ob = true

but

if db currently is null then when chkobsolete is checked
db remains null and ob remains null

Thank you so much for all your help on this. I'm really
beginning to learn from all my questions.

Thanks
Sondra
 
D

Dirk Goldgar

Sondra said:
This now works. When it wasn't working is when I
tried "yes" "no" "0" and "-1".

Hmm. I wonder if that's because, before, you didn't have the
declaration of ctl As Control. You could test that, if you wanted.
I have something more that I want to see if it is possible:

Can I define the function even more to say if:

db currently = true then when chkobsolete is checked
db=false and ob = true

but

if db currently is null then when chkobsolete is checked
db remains null and ob remains null

I'm not sure what it means to say "if db currently = true -- or false,
or Null -- then set ob to some value". As I understand it you have
multiple controls whose names are prefixed with "db" or "ob". It's easy
to pick a particular control, whether a "db" control or an "ob" control,
and set that control's value based on its current value. But if you
want to set some *other* control's value based on the value of *this*
control, how is the code to know which control you want to set?
 
G

Guest

-----Original Message-----


Hmm. I wonder if that's because, before, you didn't have the
declaration of ctl As Control. You could test that, if you wanted.


I'm not sure what it means to say "if db currently = true -- or false,
or Null -- then set ob to some value". As I understand it you have
multiple controls whose names are prefixed with "db" or "ob". It's easy
to pick a particular control, whether a "db" control or an "ob" control,
and set that control's value based on its current value. But if you
want to set some *other* control's value based on the value of *this*
control, how is the code to know which control you want to set?

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
Dirk:

Let me see if I can explain this. As you know my database
is being re-written to normalize the data. But for now
I'm working with numberous binders. Each binder has a
distribution(db)and an obsoletion(ob). Shown below:

db1 ob1
db2 ob2
db3 ob3
db4 ob4
db5 ob5

When the user enters a new document into the database she
determines which of the binders the document goes into.
For this example:

db1 true ob1 null
db2 null ob2 null
db3 true ob3 null
db4 true ob4 null
db5 null ob5 null

Six months from today the document becomes obsolete. The
user goes to the chkobsolete box and checks it. The
current function you wrote for me does this.

db1 false ob1 true
db2 false ob2 true
db3 false ob3 true
db4 false ob4 true
db5 false ob5 true

From this the user believes she has to go to binders 1-5
to remove the document when reality is she only has to go
to binders 1, 3 and 4.

So I need your help to modify the function (if possible)
to say:

db1 true ob1 null
db2 null ob2 null
db3 true ob3 null
db4 true ob4 null
db5 null ob5 null

When chkobsolete = true
if db = true then ob = true and db = false
if db = null then ob = null and db = null

I know this is complicated and probably impossible, but I
have to try. All the db's and ob's are set on either yes,
no or null(never been checked yes or no)

I hope you can help.
 
D

Dirk Goldgar

Dirk:

Let me see if I can explain this. As you know my database
is being re-written to normalize the data. But for now
I'm working with numberous binders. Each binder has a
distribution(db)and an obsoletion(ob). Shown below:

db1 ob1
db2 ob2
db3 ob3
db4 ob4
db5 ob5

When the user enters a new document into the database she
determines which of the binders the document goes into.
For this example:

db1 true ob1 null
db2 null ob2 null
db3 true ob3 null
db4 true ob4 null
db5 null ob5 null

Six months from today the document becomes obsolete. The
user goes to the chkobsolete box and checks it. The
current function you wrote for me does this.

db1 false ob1 true
db2 false ob2 true
db3 false ob3 true
db4 false ob4 true
db5 false ob5 true

From this the user believes she has to go to binders 1-5
to remove the document when reality is she only has to go
to binders 1, 3 and 4.

So I need your help to modify the function (if possible)
to say:

db1 true ob1 null
db2 null ob2 null
db3 true ob3 null
db4 true ob4 null
db5 null ob5 null

When chkobsolete = true
if db = true then ob = true and db = false
if db = null then ob = null and db = null

I know this is complicated and probably impossible, but I
have to try. All the db's and ob's are set on either yes,
no or null(never been checked yes or no)

I hope you can help.

Actually, I'm quite sure it's not impossible, and in fact quite easy,
*if* I'm right in understanding that your "ob" and "db" controls are
numbered or named so as to correspond to each other; that is, each "ob"
has a matching "db" (and vice versa), where the remainder of these two
controls' names are identical. If there's a fixed number of them, and
they are simply numbered consecutively from 1 to that number, then it's
even easier than the way you've been going about it. Let's suppose that
there are 42 "db" controls, named "db1" to "db42", and a like number of
"ob" controls, named "ob1" to "ob42". Then your logic could be
something like this:

'----- start of code -----
Private Sub Obsolete_AfterUpdate()

Dim I As Integer
Dim strDB As String
Dim strOB As String

If Me.Obsolete Then

For I = 1 To 42

strDB = "db" & I
strOB = "ob" & I

If IsNull(Me.Controls(strDB)) Then
Me.Control(strOB) = Null
ElseIf Me.Controls(strDB) = True Then
Me.Control(strOB) = True
Me.Control(strDB) = False
End If

Next I

End If

End Sub
'----- end of code -----

I believe that implements the logic you described, though of course I
could have gotten that wrong. And of course I could be wrong about the
number of db's and ob's, or the way they are named.
 
S

Sondra

-----Original Message-----


Actually, I'm quite sure it's not impossible, and in fact quite easy,
*if* I'm right in understanding that your "ob" and "db" controls are
numbered or named so as to correspond to each other; that is, each "ob"
has a matching "db" (and vice versa), where the remainder of these two
controls' names are identical. If there's a fixed number of them, and
they are simply numbered consecutively from 1 to that number, then it's
even easier than the way you've been going about it. Let's suppose that
there are 42 "db" controls, named "db1" to "db42", and a like number of
"ob" controls, named "ob1" to "ob42". Then your logic could be
something like this:

'----- start of code -----
Private Sub Obsolete_AfterUpdate()

Dim I As Integer
Dim strDB As String
Dim strOB As String

If Me.Obsolete Then

For I = 1 To 42

strDB = "db" & I
strOB = "ob" & I

If IsNull(Me.Controls(strDB)) Then
Me.Control(strOB) = Null
ElseIf Me.Controls(strDB) = True Then
Me.Control(strOB) = True
Me.Control(strDB) = False
End If

Next I

End If

End Sub
'----- end of code -----

I believe that implements the logic you described, though of course I
could have gotten that wrong. And of course I could be wrong about the
number of db's and ob's, or the way they are named.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
Dirk:

I see what everything says and I believe it should work,
but when I run it I get this:

Compile error:

Method or data member not found

I followed the help on this and verified that there were
the correct numbering of check boxes. But that wasn't the
problem.

The line it is highlighting is:

Me.Control(strOB) = Null

Hope you can help.

Sondra
 
S

Sondra

Fixed it!!! Yeah had to add an "s" to the end of

Me.Controls(strOB) = Null
ElseIf Me.Controls(strDB) = True Then
Me.Controls(strOB) = True
Me.Controls(strDB) = False

Thank you Thank you Thank you
 
D

Dirk Goldgar

Sondra said:
Fixed it!!! Yeah had to add an "s" to the end of

Me.Controls(strOB) = Null
ElseIf Me.Controls(strDB) = True Then
Me.Controls(strOB) = True
Me.Controls(strDB) = False

Oops! Sorry about that typo. I'm glad you figured out what was wrong.
Thank you Thank you Thank you

<G> You're welcome.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top