Professional Web Applications Themes

IIF statement - Microsoft Access

Assuming the data is being entered via a form, then use the AfterUpdate event of the control that is bound to the signature field. The code you need is: If Not IsNull(Me.NameOfSigControl) Then If IsNull(Me.NameOfDateControl) Then Me.NameOfDateControl = Date() End if End If (The second If statement means that an existing date will not be overwritten if the entry in the signature field is updated. This may or may not be what you want to happen). Andrew "Aurora" <asonkaydon.com> wrote in message news:8c9501c3457e$46f62c40$a401280aphx.gbl... > I am using Access 2000 > > In a form I have a signature field [IA-Sign](text ...

  1. #1

    Default Re: IIF statement

    Assuming the data is being entered via a form, then use the AfterUpdate
    event of the control that is bound to the signature field. The code you need
    is:

    If Not IsNull(Me.NameOfSigControl) Then
    If IsNull(Me.NameOfDateControl) Then
    Me.NameOfDateControl = Date()
    End if
    End If

    (The second If statement means that an existing date will not be overwritten
    if the entry in the signature field is updated. This may or may not be what
    you want to happen).

    Andrew




    "Aurora" <asonkaydon.com> wrote in message
    news:8c9501c3457e$46f62c40$a401280aphx.gbl...
    > I am using Access 2000
    >
    > In a form I have a signature field [IA-Sign](text field)
    > and a date field [IA-Date](date field). I want todays
    > date to come up automatically in the IA-Date field if and
    > when someone enters their name in the signature [IA-Sign]
    > field.
    >
    > In the date properties of IA-Date, under Validation Rule I
    > put
    > =IIf([IA-Sign] Is Not Null,[Date()]," "). But this
    > does not work. Does anyone have any ideas as to how to
    > make todays date come up only when someone has completed
    > the signature field (IA-Sign)????
    >
    > Aurora
    > .
    >
    >

    Andrew Smith Guest

  2. #2

    Default Re: IIF statement

    I appreciate your answering me so quickly. I must be
    doing something wrong because the formula will not even
    stay in the Update cell of the properties of the date
    field. This is what I did.

    I opened the form in design view. Went into the
    properties of the [IA-Date] field, to the Update cell and
    expression builder. I typed the following:

    If Not IsNull ([IA-Sign])then If IsNull ([IA-Date]) then
    [IA-Date] = Date()

    Where [IA-Sign] is the signature field and [IA-Date] is
    the date field. Can you tell what I did wrong?? The
    formula would not stay in the Update cell. When I closed
    the properties box and reopened it, the formula was gone.
    This did not work.

    Help????

    Aurora

    >-----Original Message-----
    >Assuming the data is being entered via a form, then use
    the AfterUpdate
    >event of the control that is bound to the signature
    field. The code you need
    >is:
    >
    >If Not IsNull(Me.NameOfSigControl) Then
    > If IsNull(Me.NameOfDateControl) Then
    > Me.NameOfDateControl = Date()
    > End if
    >End If
    >
    >(The second If statement means that an existing date will
    not be overwritten
    >if the entry in the signature field is updated. This may
    or may not be what
    >you want to happen).
    >
    >Andrew
    >
    >
    >
    >
    >"Aurora" <asonkaydon.com> wrote in message
    >news:8c9501c3457e$46f62c40$a401280aphx.gbl...
    >> I am using Access 2000
    >>
    >> In a form I have a signature field [IA-Sign](text field)
    >> and a date field [IA-Date](date field). I want todays
    >> date to come up automatically in the IA-Date field if
    and
    >> when someone enters their name in the signature [IA-
    Sign]
    >> field.
    >>
    >> In the date properties of IA-Date, under Validation
    Rule I
    >> put
    >> =IIf([IA-Sign] Is Not Null,[Date()]," "). But this
    >> does not work. Does anyone have any ideas as to how to
    >> make todays date come up only when someone has completed
    >> the signature field (IA-Sign)????
    >>
    >> Aurora
    >> .
    >>
    >>
    >
    >
    >.
    >
    aurora Guest

  3. #3

    Default Re: IIF statement

    Aurora,
    You've overlooked part of Andrew's post.
    >Assuming the data is being entered via a form, then use
    > the AfterUpdate
    > >event of the control that is bound to the signature
    > field. The code you need
    > >is: etc.
    This line tells you were to place the code:
    "use the AfterUpdate event of the control that is bound to the signature
    field."

    So it goes in the [IA-Sign] control AfterUpdate event, not the [IA-Date]
    event.

    As far as the code not sticking, I believe you are trying to write the code
    on the AfterUpdate property line of the control's property sheet.
    It does not go there.

    Click on the AfterUpdate event of the [IA-Sign] property sheet.
    Write [Event Procedure] on that line.
    Then click on the button with 3 dots that will appear on that line.

    When the code window opens it will have 2 lines already written for that
    event. Write Andrew's code between those 2 existing lines.
    You must change the generic names of his fields in the code to the names of
    whatever fields you are actually using.

    Here is his code using your actual control names:

    If Not IsNull(Me![IA-Sign]) Then
    If IsNull(Me![IA-Date]) Then
    Me.[IA-Date] = Date
    End if
    End If

    Also, in VBA, the Date() function does NOT need the parenthesis.

    Exit the code window.
    Run the form.

    --
    Fred

    Please reply only to this newsgroup.
    I do not reply to personal e-mail.


    "aurora" <asonkaydon.com> wrote in message
    news:03df01c34585$8e83b8f0$a301280aphx.gbl...
    > I appreciate your answering me so quickly. I must be
    > doing something wrong because the formula will not even
    > stay in the Update cell of the properties of the date
    > field. This is what I did.
    >
    > I opened the form in design view. Went into the
    > properties of the [IA-Date] field, to the Update cell and
    > expression builder. I typed the following:
    >
    > If Not IsNull ([IA-Sign])then If IsNull ([IA-Date]) then
    > [IA-Date] = Date()
    >
    > Where [IA-Sign] is the signature field and [IA-Date] is
    > the date field. Can you tell what I did wrong?? The
    > formula would not stay in the Update cell. When I closed
    > the properties box and reopened it, the formula was gone.
    > This did not work.
    >
    > Help????
    >
    > Aurora
    >
    >
    > >-----Original Message-----
    > >Assuming the data is being entered via a form, then use
    > the AfterUpdate
    > >event of the control that is bound to the signature
    > field. The code you need
    > >is:
    > >
    > >If Not IsNull(Me.NameOfSigControl) Then
    > > If IsNull(Me.NameOfDateControl) Then
    > > Me.NameOfDateControl = Date()
    > > End if
    > >End If
    > >
    > >(The second If statement means that an existing date will
    > not be overwritten
    > >if the entry in the signature field is updated. This may
    > or may not be what
    > >you want to happen).
    > >
    > >Andrew
    > >
    > >
    > >
    > >
    > >"Aurora" <asonkaydon.com> wrote in message
    > >news:8c9501c3457e$46f62c40$a401280aphx.gbl...
    > >> I am using Access 2000
    > >>
    > >> In a form I have a signature field [IA-Sign](text field)
    > >> and a date field [IA-Date](date field). I want todays
    > >> date to come up automatically in the IA-Date field if
    > and
    > >> when someone enters their name in the signature [IA-
    > Sign]
    > >> field.
    > >>
    > >> In the date properties of IA-Date, under Validation
    > Rule I
    > >> put
    > >> =IIf([IA-Sign] Is Not Null,[Date()]," "). But this
    > >> does not work. Does anyone have any ideas as to how to
    > >> make todays date come up only when someone has completed
    > >> the signature field (IA-Sign)????
    > >>
    > >> Aurora
    > >> .
    > >>
    > >>
    > >
    > >
    > >.
    > >

    Fredg Guest

  4. #4

    Default Re: IIF statement

    Aurora,
    Good question!
    In Access VBA, Me refers to the object.
    If you are writing code in a Report code window, Me! refers to that
    particular report.
    In a Form code window, Me! refers to that particular form.
    It avoids the necessity of writing the full name of the object, and allows
    the code to be easily copied and pasted into another code window, without
    then having to change the actual names of the object.
    So code written as
    forms!frmDataEntry!LastName
    would simply become
    Me!LastName

    (At a personal level, Me!Shoes would refer to Aurora's Shoes, not a friend's
    shoes, if you used it.) *

    The use of the bang (!) and the dot (.) is confusing to many people.

    My usage is
    Me![ControlName].property
    * (Me!Shoes.Brown
    Aurora's Shoes have the color property of being brown)

    is the usual method.
    Many times you can use the dot in place of the bang, but never the other way
    around.

    I changed Andrews code from the Me. to Me!, but simply overlooked that final
    Me.
    It should also have been Me!

    In reality, you could even have omitted all the Me's and the code would
    still work in this instance.

    Try it like this:

    If Not IsNull([IA-Sign]) Then
    If IsNull([IA-Date]) Then
    [IA-Date] = Date
    End if
    End If

    A good way to learn more about things like this, is to open any code window
    and simply type the word in the code sheet.
    Then place your cursor within the word and press F1.
    Access Help will open at that help file (well, most of the time).
    Try it with Me

    Good Luck.
    --
    Fred

    Please reply only to this newsgroup.
    I do not reply to personal e-mail.


    "aurora" <asonkaydon.com> wrote in message
    news:055601c34612$1053d130$a001280aphx.gbl...
    > First - Thank you for your reply and help. What you said
    > makes sense.
    > Second - As you probably have guessed, I am not a
    > programmer. Therefore, can you tell me what "Me!" is in
    > the code line or do I type it as is. Also in the 3rd line
    > of code that you wrote, does "Me." mean something
    > different or should it be "Me!"?
    >
    > Again, thank you for your help.
    >
    > Aurora
    > >-----Original Message-----
    > >Aurora,
    > >You've overlooked part of Andrew's post.
    > >
    > >>Assuming the data is being entered via a form, then use
    > >> the AfterUpdate
    > >> >event of the control that is bound to the signature
    > >> field. The code you need
    > >> >is: etc.
    > >
    > >This line tells you were to place the code:
    > >"use the AfterUpdate event of the control that is bound
    > to the signature
    > >field."
    > >
    > >So it goes in the [IA-Sign] control AfterUpdate event,
    > not the [IA-Date]
    > >event.
    > >
    > >As far as the code not sticking, I believe you are trying
    > to write the code
    > >on the AfterUpdate property line of the control's
    > property sheet.
    > >It does not go there.
    > >
    > >Click on the AfterUpdate event of the [IA-Sign] property
    > sheet.
    > >Write [Event Procedure] on that line.
    > >Then click on the button with 3 dots that will appear on
    > that line.
    > >
    > >When the code window opens it will have 2 lines already
    > written for that
    > >event. Write Andrew's code between those 2 existing lines.
    > >You must change the generic names of his fields in the
    > code to the names of
    > >whatever fields you are actually using.
    > >
    > >Here is his code using your actual control names:
    > >
    > >If Not IsNull(Me![IA-Sign]) Then
    > > If IsNull(Me![IA-Date]) Then
    > > Me.[IA-Date] = Date
    > > End if
    > >End If
    > >
    > >Also, in VBA, the Date() function does NOT need the
    > parenthesis.
    > >
    > >Exit the code window.
    > >Run the form.
    > >
    > >--
    > >Fred
    > >
    > >Please reply only to this newsgroup.
    > >I do not reply to personal e-mail.
    > >
    > >
    > >"aurora" <asonkaydon.com> wrote in message
    > >news:03df01c34585$8e83b8f0$a301280aphx.gbl...
    > >> I appreciate your answering me so quickly. I must be
    > >> doing something wrong because the formula will not even
    > >> stay in the Update cell of the properties of the date
    > >> field. This is what I did.
    > >>
    > >> I opened the form in design view. Went into the
    > >> properties of the [IA-Date] field, to the Update cell
    > and
    > >> expression builder. I typed the following:
    > >>
    > >> If Not IsNull ([IA-Sign])then If IsNull ([IA-Date]) then
    > >> [IA-Date] = Date()
    > >>
    > >> Where [IA-Sign] is the signature field and [IA-Date] is
    > >> the date field. Can you tell what I did wrong?? The
    > >> formula would not stay in the Update cell. When I
    > closed
    > >> the properties box and reopened it, the formula was
    > gone.
    > >> This did not work.
    > >>
    > >> Help????
    > >>
    > >> Aurora
    > >>
    > >>
    > >> >-----Original Message-----
    > >> >Assuming the data is being entered via a form, then use
    > >> the AfterUpdate
    > >> >event of the control that is bound to the signature
    > >> field. The code you need
    > >> >is:
    > >> >
    > >> >If Not IsNull(Me.NameOfSigControl) Then
    > >> > If IsNull(Me.NameOfDateControl) Then
    > >> > Me.NameOfDateControl = Date()
    > >> > End if
    > >> >End If
    > >> >
    > >> >(The second If statement means that an existing date
    > will
    > >> not be overwritten
    > >> >if the entry in the signature field is updated. This
    > may
    > >> or may not be what
    > >> >you want to happen).
    > >> >
    > >> >Andrew
    > >> >
    > >> >
    > >> >
    > >> >
    > >> >"Aurora" <asonkaydon.com> wrote in message
    > >> >news:8c9501c3457e$46f62c40$a401280aphx.gbl...
    > >> >> I am using Access 2000
    > >> >>
    > >> >> In a form I have a signature field [IA-Sign](text
    > field)
    > >> >> and a date field [IA-Date](date field). I want
    > todays
    > >> >> date to come up automatically in the IA-Date field if
    > >> and
    > >> >> when someone enters their name in the signature [IA-
    > >> Sign]
    > >> >> field.
    > >> >>
    > >> >> In the date properties of IA-Date, under Validation
    > >> Rule I
    > >> >> put
    > >> >> =IIf([IA-Sign] Is Not Null,[Date()]," "). But
    > this
    > >> >> does not work. Does anyone have any ideas as to how
    > to
    > >> >> make todays date come up only when someone has
    > completed
    > >> >> the signature field (IA-Sign)????
    > >> >>
    > >> >> Aurora
    > >> >> .
    > >> >>
    > >> >>
    > >> >
    > >> >
    > >> >.
    > >> >
    > >
    > >
    > >.
    > >

    Fredg Guest

Similar Threads

  1. help on SQL statement
    By filippo2991@virgilio.it in forum MySQL
    Replies: 2
    Last Post: June 9th, 01:13 PM
  2. [PHP] SQL statement
    By Chris W. Parker in forum PHP Development
    Replies: 14
    Last Post: September 28th, 03:48 PM
  3. if statement with url
    By John in forum PHP Development
    Replies: 5
    Last Post: September 11th, 03:13 AM
  4. if statement
    By alexz in forum ASP
    Replies: 8
    Last Post: July 15th, 04:57 PM
  5. Can i say OR in an if/then statement
    By crispy in forum ASP
    Replies: 6
    Last Post: July 9th, 07:27 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139