Results 1 to 9 of 9
  1. #1
    sergran is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jun 2013
    Posts
    115

    Valore Null

    Hello, I need your help .... if you can
    I have a text box handled by this VBA code


    Dim ValoreEsistente, MioConteggio As String
    ValoreEsistente = Me.Voto_04
    MioConteggio = Left (ValoreEsistente, 3)
    If MioConteggio = "04 -" Then
    Exit Sub
    else
    [Voto_04]. Value = "04 -" & Me [Voto_04]
    end If
    It works, but if you do not insert any given me an error is returned. I tried to write
    If [Voto_04]. Value is null
    Exit Sub
    end if
    but it does not work ...
    sigh sigh

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You have to use the IsNull() function:
    Code:
      Dim ValoreEsistente As String
      Dim MioConteggio As String
    
      ValoreEsistente = Me.Voto_04
      MioConteggio = Left(ValoreEsistente, 3) ' see below
    
      If MioConteggio = "04 -" Or IsNull(ValoreEsistente) Then
        Exit Sub
      Else
        Me.[Voto_04] = "04 -" & ValoreEsistente
      End If
    -------------------------
    Other items:
    Don't have to type ".Value" ...... VALUE is the default property.

    If there is a space in the string "04 -", the length is 4, not 3. (zero, four, space,dash)

    The line
    [Voto_04]. Value = "04 -" & Me [Voto_04] - is missing a dot between "ME" and "[Voto_04]"

    The variable "ValoreEsistente" is declared as a Variant, "MioConteggio" is declared as a String.

  3. #3
    sergran is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jun 2013
    Posts
    115
    Hello, i my sorry but I can not figure out how to run the code. I brought him back in the field Voto_04 but does not work. I attach the database .. could you give us a look?
    Attached Files Attached Files

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Where did you copy the code from?

    It works, but if you do not insert any given me an error is returned.
    If it (the code) works, put the revised code in the same place.
    But I will look at your example......

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Seems to be working fine. Because of the event you selected, you have to exit the field for the code to run.

    Also, you should have these two lines at the top of every code page:

    Option Compare Database
    Option Explicit


    In the IDE, goto TOOLS/OPTIONS/ Editor tab, make sure that "Require Variable Declaration" is checked. This will add the line "Option Explicit" to all NEW code pages.

    Under access options, Current database, uncheck the two options for "Name AutoCorrect?



    You can use the code in "Private Sub Voto_04_Exit(Cancel As Integer)" as a guide for all of the other Traccia combo boxes.
    Instead of the EXII event, I probably would have used the AFTERUPDATE event......

  6. #6
    sergran is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jun 2013
    Posts
    115
    Forgive me but I can not understand ... sorry but programming is "0". Can you please change the db I have attached for what concerns the text box Voto_04? Then for the other fields I'll .. thanks

  7. #7
    sergran is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jun 2013
    Posts
    115
    I'm sorry but I just can not .....

  8. #8
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    The code for "Voto_04" is working, as far as I can tell. Why do you think it is not working?

  9. #9
    sergran is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jun 2013
    Posts
    115
    Hello, I always appears the error "Run-time 94" when Voto_04 not insert any data. Definitely something I'm wrong, so I ask you if you could please look at the attached database ...
    hello thanks

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

Similar Threads

  1. If/Then Null based on Null Value of Another Field
    By vbpeterson in forum Queries
    Replies: 11
    Last Post: 06-05-2012, 05:00 PM
  2. Replies: 1
    Last Post: 02-23-2012, 02:27 PM
  3. Finding the Max Date and Null Values if Null
    By SpdRacerX in forum Queries
    Replies: 1
    Last Post: 02-03-2012, 06:29 AM
  4. Passing criteria "NULL" or "IS NOT NULL" to a query
    By SgtSaunders69 in forum Forms
    Replies: 1
    Last Post: 12-24-2011, 02:22 AM
  5. Update field1 if Null, if Not Null update field2
    By mfirestorm in forum Queries
    Replies: 2
    Last Post: 12-02-2011, 09:51 AM

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