Results 1 to 4 of 4
  1. #1
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    284

    Trying to Use a Function to Set a String Variable

    Greetings All...

    Again, seems like it should be easy.... buuuut, here I am...

    So, what I am trying to do is set the value of a string variable equal to the result of an Iif Function...



    (based on the fact I can't even get it to stop turning red...I'm not even close.

    Code:
    Dim TAdd As String
    Set TAdd = (Iif Me.CmboSalesList.Column(2) = "Null" Then "Yes", "No")
    I'm trying the idea of using a SQL statement as you read...But I hope from the above you can capture the idea I'm going for

    And... As Always - Thank You Guys Very Much...

  2. #2
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    Your syntax is completely wrong and you are mishandling doing null check
    Remove the Set and rewrite as follows

    Code:
    TAdd=IIf(IsNull(Me.cmboSalesList.Column(2)),"Yes","No")
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  3. #3
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    284
    Geez... I was backwards...and possibly inside out...

    Works perfectly ~

    Thanks Ridders!

  4. #4
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    Upside down as well...
    Anyway glad to have helped
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 7
    Last Post: 09-23-2016, 01:04 PM
  2. Replies: 6
    Last Post: 06-20-2016, 01:29 PM
  3. Replies: 3
    Last Post: 06-08-2014, 05:36 PM
  4. Trouble with string variable in custom vba function
    By CurrentUser in forum Programming
    Replies: 4
    Last Post: 01-10-2014, 09:13 PM
  5. Replies: 3
    Last Post: 05-28-2013, 12:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums