Results 1 to 9 of 9
  1. #1
    wes9659 is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Apr 2014
    Location
    Dover, Ohio
    Posts
    88

    Using Null with Marco

    I am some issue on my use of null value. What I would like to do is using the even “On Exit” from a field in this case “SecondaryContactName” which is a short text field. What I would like is if the field is left empty I want it to go to field named “ServiceType1”
    I created the macro in Photo1 but it does not work correctly. Photo2 shows form and where I want it to jump to. Once again thanks all for the help
    . Click image for larger version. 

Name:	Photo1.png 
Views:	13 
Size:	27.3 KB 
ID:	19995Click image for larger version. 

Name:	Photo2.jpg 
Views:	13 
Size:	176.3 KB 
ID:	19996

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Try

    If Nz(FieldName, "") = "" Then
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    wes9659 is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Apr 2014
    Location
    Dover, Ohio
    Posts
    88
    Hi pbaldy, I tried to follow what you said and received a Parse the expression error. See attached photos am I not entering it right?. Thank you for all your help as well as everyone else here. First Photo shows help that pop up and second shows the error
    Click image for larger version. 

Name:	Photo4.jpg 
Views:	11 
Size:	70.1 KB 
ID:	20001Click image for larger version. 

Name:	Photo5.jpg 
Views:	11 
Size:	119.8 KB 
ID:	20002

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I don't (read *Never*) use macros, but I would suggest trying:

    Code:
    Nz(FieldName, "")
    I think, but I could be wrong, the macro will not know what to do with the "IF" or the "THEN"

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    I don't use macros either, but that appears correct Steve.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    wes9659 is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Apr 2014
    Location
    Dover, Ohio
    Posts
    88
    That does not do it exactly ssanfu it does move it but also moves it there when something in field and it makes program not work quite right.
    How would you recommend writing the action In VBA code?
    Basically once I Exit Field Named SecondaryContactName if field is Null I want to go to field named ServiceType1 and continue on from there. If SecondaryContactName field contains data I want it to continue on to next corresponding field. It’s the Null value that is throwing me for a loop. Thanks everyone for your help and support. I truly appreciate it.

  7. #7
    wes9659 is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Apr 2014
    Location
    Dover, Ohio
    Posts
    88
    Do I need to Write another if statement in regards to If it is not null than go to the next record? I assume VBA would be best choice but not quite sure on implementation as I previously post. Thank you

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    In VBA I'd use

    If Len(Me.ControlName & vbNullString) = 0 Then
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    This is how I would write the VBA:
    Code:
    Private Sub SecondaryContactName_Exit(Cancel As Integer)
        If Len(Me.SecondaryContactName & vbNullString) = 0 Then
            Me.servicetype1.SetFocus
        End If
    End Sub

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

Similar Threads

  1. Marco: Export to Excel w/o Formatting
    By AKoval in forum Import/Export Data
    Replies: 1
    Last Post: 03-20-2013, 09:14 AM
  2. marco needed to add a certain number of records
    By askjacq in forum Programming
    Replies: 2
    Last Post: 02-09-2013, 12:45 PM
  3. Replies: 1
    Last Post: 02-23-2012, 02:27 PM
  4. Finding the Max Date and Null Values if Null
    By SpdRacerX in forum Queries
    Replies: 1
    Last Post: 02-03-2012, 06:29 AM
  5. Marco to split up and save a report
    By jjsaw5 in forum Programming
    Replies: 1
    Last Post: 02-02-2012, 01:33 PM

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