Results 1 to 4 of 4

Thread: If.. Then.

  1. #1
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    If.. Then.

    Access 97, part of O97, SR2

    I'm trying to use the following code to enable pages as appropriate. These pages are on a subform. The 'parent' data set contains values for 4 seperate entities in this case, each contains an ID that refers to another table.

    Sub Form_BeforeUpdate()
    if parent.stateID1.value = null then pgstate1.enabled = false
    if parent.stateID2.value = null then pgstate2.enabled = false
    if parent.stateID3.value = null then pgstate3.enabled = false
    if parent.stateID4.value = null then pgstate4.enabled = false
    end Sub

    The problem is, i'm not using a valid method for referring to StateID* on the parent form. Can anyone help?
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: If.. Then.

    Actually, your big problem is that your code won't produce the result you want. Any code that equates to null will result in Null, even NULL=NULL will yield NULL and not true! You need to test by using IsNull or Not IsNull.

    As for not using a valid method to refere to the controls on the mainform, what you quoted should work provided that State1ID is actually a named control on the main form. I prefer to use Me.Parent.StateID as it is clearer what I'm referring to.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: If.. Then.

    You could also simplify it like this:

    <pre>Sub Form_BeforeUpdate()
    pgstate1.enabled = not isnull(Parent!stateID1)
    pgstate2.enabled = not isnull(Parent!stateID2)
    pgstate3.enabled = not isnull(Parent!stateID3)
    pgstate4.enabled = not isnull(Parent!stateID4 )
    end Sub</pre>

    That will return a False (Not True) if the StateID# field is null and a true if the field is not null. Is that what you were trying to do?
    Charlotte

  4. #4
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: If.. Then.

    Well, each professional has credentials from at least one state agency, however in some states, they have several state agencies.

    I think your code will work, I want to setup four tabs, or four buttons perhaps, to update the screen with stateagencyid2 if applicable, (or 3, or 4...) If they're not applicable, these controls will not be enabled.

    I'll let you know if/when it works!

    Thanks! <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •