Results 1 to 6 of 6
  1. #1
    CementCarver's Avatar
    CementCarver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    231

    Dealing With Incoming Null values - Variants

    I have a form that my client may or may not complete when they're inputting data. Therefore, there may be causes where a null value is being passed with the assignment of ctl.value.

    After some research, it's been stated that you should use a variant to deal with this incoming null value. I'm not exactly sure how to implement variants. So any input would be much appreciated..... here's a snippet of my code:

    For Each ctl In Screen.ActiveForm.Controls


    If ctl.Tag = "Audit" Then
    With rstAudit
    .AddNew
    ![DateTime] = datTimeCheck
    ![UserName] = strUserID
    ![FormName] = Screen.ActiveForm.Name
    ![Action] = UserAction
    ![Record_ID] = MaxMember_id
    ![FieldName] = ctl.ControlSource
    ![NewValue] = ctl.Value ---------------this the line causing the error.....
    .Update
    End With
    End If
    Next ctl

    CementCarver

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Why not use the Nz() function?
    ![NewValue] = Nz(ctl.Value,0) - If you want a zero or...
    ![NewValue] =Nz(ctl.Value,"") - If you want a ZeroLengthString (ZLS)

  3. #3
    CementCarver's Avatar
    CementCarver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    231
    Thanks for your suggestion RuralGuy, but when I try the second line, I get an error run time error 2424, the expression you've entered has a field, control or property that Access can't find.

    CementCarver

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You only used one of those lines right?

  5. #5
    CementCarver's Avatar
    CementCarver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    231
    Yes, just the second one.

    CementCarver

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Single step the code and see which element it does not like.

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

Similar Threads

  1. Integrating Incoming Email into Access DB
    By andytreusch in forum Forms
    Replies: 3
    Last Post: 08-14-2013, 06:14 PM
  2. Finding the Max Date and Null Values if Null
    By SpdRacerX in forum Queries
    Replies: 1
    Last Post: 02-03-2012, 06:29 AM
  3. Replies: 3
    Last Post: 01-20-2012, 04:46 PM
  4. How do I convert an incoming object to binary?
    By techneophyte in forum Programming
    Replies: 1
    Last Post: 07-28-2010, 10:42 AM
  5. Replies: 1
    Last Post: 05-20-2009, 09:09 AM

Tags for this Thread

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