Results 1 to 7 of 7

Thread: MS access 2003- update null fields

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    586

    Question MS access 2003- update null fields

    Hi,

    I'm trying to update an unbound form fields back into the table using a recordset.

    I'm having troubles with Null values.

    Here's the code:

    rst!Field1= nz(me.field1,Null)

    - However, this seems to fail no matter what I put for the nz null value.

    The only thing that seems to work is pretty clumsy:

    If Nz(Me.Field1, "") = "" Then
    rst!Field1 = Null
    Else
    rst!Field1 = Me.Field1
    End If

    Any other suggestions?

    Thanks,

  2. #2
    Fanatic Member BillBoeBaggins's Avatar
    Join Date
    Jan 2003
    Location
    in your database, dropping your tables.
    Posts
    628

    Re: MS access 2003- update null fields

    What is "Nz" is that a custom function or a function I have never seen before?
    What errors are you getting, or what is it doing that your not sure why?

    Can this "Nz" function accept Null parameters?

  3. #3
    Addicted Member Smartacus's Avatar
    Join Date
    Oct 2009
    Location
    Deep South, USA
    Posts
    196

    Re: MS access 2003- update null fields

    Nz lets you return a value when a variant is null
    ***************************************************
    Smartacus comes packaged "As Is With No Warranty"

    ************* Useful Links ******************
    FAQs: Index / Database Development / .NET CodeBank /
    Before Posting Here...MSDN

    MZTools (I love this tool when using VB6 - Free) /

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    586

    Re: MS access 2003- update null fields

    So, any ideas about this?

  5. #5
    Fanatic Member BillBoeBaggins's Avatar
    Join Date
    Jan 2003
    Location
    in your database, dropping your tables.
    Posts
    628

    Re: MS access 2003- update null fields

    rst!Field1= nz(me.field1,Null)
    So am I reading this right?
    If me.field1 Is Null Then Null Else Me.Field1
    ......
    So I take it the field is not true Null it is "", but you want it to be loaded with Null if "". So your Nz is not returning Null back on your first line because it is "", Not Null.

    Do you have field restrictions that are preventing it from being assigned ""?

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    586

    Re: MS access 2003- update null fields

    Hi,

    I'm not sure I understand the question but it is an unbound form, and the DB is mySQL.

    Thanks

  7. #7
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: MS access 2003- update null fields

    Try this

    Code:
    Dim varFld
    varFld = Me.Field1
    rst!Field1= nz(varFld,Null)
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

Posting Permissions

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



Click Here to Expand Forum to Full Width